-
Notifications
You must be signed in to change notification settings - Fork 0
/
svg_to_ico_folder.sh
44 lines (36 loc) · 1.89 KB
/
svg_to_ico_folder.sh
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
#!/bin/bash
SCRIPT_PATH=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
cd $SCRIPT_PATH
echo $SCRIPT_PATH
read -p "Enter SVG folder path: " EMOJI_DIR
SRC_FOLDER=$SCRIPT_PATH/src/folder
TMP_FOLDER=$SCRIPT_PATH/tmp/folder
DIST_FOLDER=$SCRIPT_PATH/dist/folder
mkdir -p $DIST_FOLDER
FILES=$EMOJI_DIR/*.svg
for f in $FILES
do
echo "Processing $(basename "${f%.*}") file..."
# Take action on each file. $f store current file name
mkdir -p "$TMP_FOLDER/$(basename "${f%.*}")"
cd "$TMP_FOLDER/$(basename "${f%.*}")"
rsvg-convert "$f" -w 120 -h 120 -o emoji_256.png
rsvg-convert "$f" -w 32 -h 32 -o emoji_64.png
rsvg-convert "$f" -w 24 -h 24 -o emoji_48.png
rsvg-convert "$f" -w 20 -h 20 -o emoji_40.png
rsvg-convert "$f" -w 16 -h 16 -o emoji_32.png
rsvg-convert "$f" -w 12 -h 12 -o emoji_24.png
rsvg-convert "$f" -w 10 -h 10 -o emoji_20.png
# Composite the folder icon
magick composite -gravity SouthEast -geometry +16+29 emoji_256.png "$SRC_FOLDER/256.png" compositeicon_256.png
magick composite -gravity SouthEast -geometry +4+6 emoji_64.png "$SRC_FOLDER/64.png" compositeicon_64.png
magick composite -gravity SouthEast -geometry +3+6 emoji_48.png "$SRC_FOLDER/48.png" compositeicon_48.png
magick composite -gravity SouthEast -geometry +2+5 emoji_40.png "$SRC_FOLDER/40.png" compositeicon_40.png
magick composite -gravity SouthEast -geometry +3+3 emoji_32.png "$SRC_FOLDER/32.png" compositeicon_32.png
magick composite -gravity SouthEast -geometry +1+3 emoji_24.png "$SRC_FOLDER/24.png" compositeicon_24.png
magick composite -gravity SouthEast -geometry +2+2 emoji_20.png "$SRC_FOLDER/20.png" compositeicon_20.png
# Make the .ico
magick convert compositeicon_256.png compositeicon_64.png compositeicon_48.png compositeicon_40.png compositeicon_32.png compositeicon_24.png compositeicon_20.png emoji_32.png "$DIST_FOLDER/$(basename "${f%.*}").ico"
cd ../../../
rm -rf "$TMP_FOLDER/$(basename "${f%.*}")"
done