-
Notifications
You must be signed in to change notification settings - Fork 5
/
make
executable file
·89 lines (66 loc) · 2.38 KB
/
make
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
#
# Requires Inkscape 1.0+, pngqaunt.
set -ex
# Remove existing directories and their contents
rm -fr black/* white/* colour/* outline/* pdf/*
# Create new directories
mkdir -pv black white colour outline pdf/colour pdf/black pdf/white pdf/outline
# Function to convert SVG files to PNG and move them to the specified directory
svg_to_png() {
local source_dir="$1"
local destination_dir="$2"
find "$source_dir" -type f -name '*.svg' -exec inkscape --export-type=png {} +
mv "$source_dir"/*.png "$destination_dir"
}
# Function to convert SVG files to PDF and move them to the specified directory
svg_to_pdf() {
local source_dir="$1"
local destination_dir="$2"
find "$source_dir" -type f -name '*.svg' -exec inkscape --export-type=pdf {} +
mv "$source_dir"/*.pdf "$destination_dir"
}
# Create White icons
svg_to_png "./svg/white" "white"
svg_to_pdf "./svg/white" "pdf/white"
# Create Black icons
svg_to_png "./svg/black" "black"
svg_to_pdf "./svg/black" "pdf/black"
# Create Colour icons
svg_to_png "./svg/colour" "colour"
svg_to_pdf "./svg/colour" "pdf/colour"
# Create Outline icons
svg_to_png "./svg/outline" "outline"
svg_to_pdf "./svg/outline" "pdf/outline"
# Check if pngquant is installed
if ! command -v pngquant &> /dev/null; then
echo "Error: pngquant is not installed. Please install it before running this script."
exit 1
fi
# Compress PNG icons using pngquant.
find ./ -type f -name '*.png' -exec pngquant --force --ext .png {} +
## Create icon.csv ##
# Specify the source directory path
source_directory="svg/black"
# Specify the output CSV file
output_csv="icon.csv"
# Specify the destination directory for the CSV file
destination_directory="../../"
# Navigate to the source directory
cd "$source_directory" || exit
# Create or overwrite the CSV file with a header
echo "File Name" > "$output_csv"
# Loop through each file in the directory
for file in *; do
# Check if it is a regular file (not a directory) and not the output CSV file
if [ -f "$file" ] && [ "$file" != "$output_csv" ]; then
# Extract the file name without extension
file_name=$(basename "$file")
file_name_no_ext="${file_name%.*}"
# Append the entry to the CSV file
echo "$file_name_no_ext" >> "$output_csv"
fi
done
# Move the CSV file to the destination directory
mv "$output_csv" "$destination_directory"
exit