-
Notifications
You must be signed in to change notification settings - Fork 0
/
AppIconGenerator.sh
136 lines (99 loc) · 3.06 KB
/
AppIconGenerator.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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/sh
if [ ! -n "$1" ] ;then
echo "\033[31m 没有传入参数,需要传入执行的图片路径 \033[0m"
exit
else
echo "\033[32m 开始执行 \033[0m"
fi
echo "-------------------------开始裁剪Appicon---------------------------"
filename="$1"
dirname="AppIcon.appiconset"
author="jianxiong"
filename_array=("iphone_Notification_20pt@2x.png" "iphone_Notification_20pt@3x.png"\
"iphone_Setting_29pt@2x.png" "iphone_Setting_29pt@3x.png"\
"iphone_Spotlight_40pt@2x.png" "iphone_Spotlight_40pt@3x.png"\
"iphone_App_60pt@2x.png" "iphone_App_60pt@3x.png"\
"ipad_Notification_20pt@1x.png" "ipad_Notification_20pt@2x.png"\
"ipad_Setting_29pt@1x.png" "ipad_Setting_29pt@2x.png"\
"ipad_Spotlight_40pt@1x.png" "ipad_Spotlight_40pt@2x.png"\
"ipad_App_76pt@1x.png" "ipad_App_76pt@2x.png"\
"ipad_Pro_App_83.5pt@2x.png"\
"ios-marketing_Store_1024pt@1x.png")
commonsize_array=("20" "20"\
"29" "29"\
"40" "40"\
"60" "60"\
"20" "20"\
"29" "29"\
"40" "40"\
"76" "76"\
"83.5"\
"1024")
size_array=("40" "60"\
"58" "87"\
"80" "120"\
"120" "180"\
"20" "40"\
"29" "58"\
"40" "80"\
"76" "152"\
"167"\
"1024")
mkdir $dirname
#添加描述文件
files=`find filename -name "*.png"`
for i in ${files[@]};
do
echo "+++${i}"
SOURCE_FILE=${i}
DESTINATION_FILE=$SOURCE_FILE
sips \--matchTo '/System/Library/ColorSync/Profiles/sRGB Profile.icc' $SOURCE_FILE \--out $DESTINATION_FILE
done
echo "----------开始裁剪---------"
for ((i=0;i<${#size_array[@]};++i)); do
mkdir $dirname
m_dir=$dirname/${filename_array[i]}
echo $filename $m_dir
cp $filename $m_dir
sips -Z ${size_array[i]} $m_dir
done
cd $dirname
echo "----------开始生成Content.json---------"
echo { >> Contents.json
echo " \"images\"" : [>> Contents.json
for (( i = 0; i < ${#size_array[@]}; ++i )); do
#statements
imageName=${filename_array[i]}
IFS='@' arr=($imageName)
IFS='_' idiomArr=($imageName)
temp=${arr[1]}
scaleStr=${temp:0:2}
scale=${temp:0:1}
size=${size_array[i]}
# commonSize=$(echo "${size}/${scale}"|bc)
commonsize=${commonsize_array[i]}
idiom=${idiomArr[0]}
echo "--------------------------------"
echo "size:${commonsize}x${commonsize}"
echo "filename:$imageName"
echo "scale:$scale"
echo "idiom:$idiom"
echo "--------------------------------"
echo " "{>> Contents.json
echo " \"size\"" : "\"${commonsize}x${commonsize}\"",>> Contents.json
echo " \"idiom\"" : "\"$idiom\"",>> Contents.json
echo " \"filename\"" : "\"$imageName\"",>> Contents.json
echo " \"scale\"" : "\"$scaleStr\"">> Contents.json
echo " "},>> Contents.json
done
echo " "],>> Contents.json
echo " \"info\"" : {>> Contents.json
echo " \"version\"" : 1,>> Contents.json
echo " \"author\"" : "\"$author\"">> Contents.json
echo " "}>> Contents.json
echo }>> Contents.json
echo "-------------------------裁剪结束--------------------------"
cd ..
echo "生成图标数个数为: ${#filename_array[*]}"
echo "文件大小:$(du -h $dirname)"
echo "\033[36;1m总用时: ${SECONDS}s \033[0m"