forked from sunho/SDStudio
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgen.sh
More file actions
executable file
·59 lines (44 loc) · 1.39 KB
/
gen.sh
File metadata and controls
executable file
·59 lines (44 loc) · 1.39 KB
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
#!/bin/sh
if ! [ -x "$(command -v convert)" ]; then
echo 'Error: ImageMagick is not installed' >&2
echo 'Use brew install imagemagick on Mac OS X' >&2
exit 1
fi
if [ $# -eq 0 ]; then
echo 'Usage: generate-icons.sh <1024x1024 icon file name.png>' >&2
exit 1
fi
filename="$1"
iconset_dir="${filename%.*}".iconset
mkdir -p icons
mkdir -p $iconset_dir
declare -a web_sizes=("16" "24" "32" "48" "64" "96" "128" "256" "512" "1024")
declare -a icns_sizes=("16" "32" "64" "128" "256" "512")
for i in "${web_sizes[@]}"
do
echo "Processing $resized_path"
resized_path="./icons/${i}x${i}.png"
convert -background none -resize "!${i}x${i}" "$1" "$resized_path"
# Mac OS X iconset
for item in "${icns_sizes[@]}"; do
if [[ $i == "$item" ]]; then
cp $resized_path "./$iconset_dir/icon_${i}x${i}.png"
if [[ "$prev_size" ]]
then
cp $resized_path "./$iconset_dir/icon_${prev_size}@2x.png"
fi
prev_size="${i}x${i}"
fi
done
done
# 1024x1024 icon
cp "./icons/1024x1024.png" "./$iconset_dir/icon_512x512@2x.png"
echo Generating uniform PNG...
cp icons/256x256.png ./icon.png
echo Generating Mac OS X iconset...
iconutil --convert icns "$iconset_dir" --output icon.icns
echo Generating Windows ICO...
convert "$1" -define icon:auto-resize icon.ico
echo Cleaning up...
rm -rf $iconset_dir
echo All done.