Last active
March 7, 2019 08:35
-
-
Save scue/a545606760085a6e3fac01e232b67cda to your computer and use it in GitHub Desktop.
iOS应用程序图标(AppIcon.appiconset)快速制作脚本
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# PNG2AppIcon-iOS.sh | |
# | |
# | |
# Created by scue on 2019/3/7. | |
# | |
img_names=( | |
Icon1024.png | |
Icon20.png | |
[email protected] | |
[email protected] | |
[email protected] | |
Icon29.png | |
[email protected] | |
[email protected] | |
[email protected] | |
Icon40.png | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
[email protected] | |
Icon76.png | |
[email protected] | |
[email protected] | |
) | |
img_sizes=( | |
1024x1024 | |
20x20 | |
40x40 | |
40x40 | |
60x60 | |
29x29 | |
58x58 | |
58x58 | |
87x87 | |
40x40 | |
80x80 | |
80x80 | |
120x120 | |
120x120 | |
180x180 | |
76x76 | |
152x152 | |
167x167 | |
) | |
set -e | |
if [[ $# -lt 1 ]]; then | |
echo "usage: $0 <file.png>" | |
exit 1 | |
fi | |
input=$1 | |
output=AppIcon.appiconset | |
mkdir ${output} | |
# step 1: convert png | |
index=0 | |
for name in ${img_names[@]}; do | |
size=${img_sizes[index]} | |
( | |
set -x | |
convert ${input} -resize ${size} ${output}/${name} | |
) | |
((index++)) | |
done | |
# step 2: generate Contents.json | |
echo "create ${output}/Contents.json" | |
cat <<'EOF' > ${output}/Contents.json | |
{ | |
"images" : [ | |
{ | |
"size" : "20x20", | |
"idiom" : "iphone", | |
"filename" : "[email protected]", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "20x20", | |
"idiom" : "iphone", | |
"filename" : "[email protected]", | |
"scale" : "3x" | |
}, | |
{ | |
"size" : "29x29", | |
"idiom" : "iphone", | |
"filename" : "[email protected]", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "29x29", | |
"idiom" : "iphone", | |
"filename" : "[email protected]", | |
"scale" : "3x" | |
}, | |
{ | |
"size" : "40x40", | |
"idiom" : "iphone", | |
"filename" : "[email protected]", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "40x40", | |
"idiom" : "iphone", | |
"filename" : "[email protected]", | |
"scale" : "3x" | |
}, | |
{ | |
"size" : "60x60", | |
"idiom" : "iphone", | |
"filename" : "[email protected]", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "60x60", | |
"idiom" : "iphone", | |
"filename" : "[email protected]", | |
"scale" : "3x" | |
}, | |
{ | |
"size" : "20x20", | |
"idiom" : "ipad", | |
"filename" : "Icon20.png", | |
"scale" : "1x" | |
}, | |
{ | |
"size" : "20x20", | |
"idiom" : "ipad", | |
"filename" : "[email protected]", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "29x29", | |
"idiom" : "ipad", | |
"filename" : "Icon29.png", | |
"scale" : "1x" | |
}, | |
{ | |
"size" : "29x29", | |
"idiom" : "ipad", | |
"filename" : "[email protected]", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "40x40", | |
"idiom" : "ipad", | |
"filename" : "Icon40.png", | |
"scale" : "1x" | |
}, | |
{ | |
"size" : "40x40", | |
"idiom" : "ipad", | |
"filename" : "[email protected]", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "76x76", | |
"idiom" : "ipad", | |
"filename" : "Icon76.png", | |
"scale" : "1x" | |
}, | |
{ | |
"size" : "76x76", | |
"idiom" : "ipad", | |
"filename" : "[email protected]", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "83.5x83.5", | |
"idiom" : "ipad", | |
"filename" : "[email protected]", | |
"scale" : "2x" | |
}, | |
{ | |
"size" : "1024x1024", | |
"idiom" : "ios-marketing", | |
"filename" : "Icon1024.png", | |
"scale" : "1x" | |
} | |
], | |
"info" : { | |
"version" : 1, | |
"author" : "xcode" | |
} | |
} | |
EOF | |
echo "Done, please output directory: ${output}." | |
#convert ${filename} -resize $size ${dirname}/${pdfname} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
运行结果: