-
Notifications
You must be signed in to change notification settings - Fork 0
/
png2icns.sh
executable file
·55 lines (44 loc) · 1.69 KB
/
png2icns.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
#! /bin/bash
if [ ! -x "/usr/bin/sips" ]; then
echo "失败:未找到可执行的SIPS "
echo "Failed: Cannot find required SIPS executable at: /usr/bin/sips "
exit;
fi
if [ ! -x "/usr/bin/iconutil" ]; then
echo "失败:未找到可执行的ICONUTIL "
echo "Failed: Cannot find required ICONUTIL executable at: /usr/bin/iconutil "
exit;
fi
read -p "Please enter the path to your source PNG image:" FILENAME
if [ ! -f "${FILENAME}" ]; then
echo "失败:图片未找到!"
echo "Failed: Image Not Found!"
exit;
fi
if [[ $FILENAME == *.png ]];then
DIRNAME='icon-'`date +"%Y-%m-%d-%H:%M:%S"`
cd /tmp
mkdir $DIRNAME
cd $DIRNAME
cp $FILENAME icon.png
mkdir icon.iconset
sips -z 16 16 icon.png --out icon.iconset/icon_16x16.png
sips -z 32 32 icon.png --out icon.iconset/[email protected]
sips -z 32 32 icon.png --out icon.iconset/icon_32x32.png
sips -z 64 64 icon.png --out icon.iconset/[email protected]
sips -z 128 128 icon.png --out icon.iconset/icon_128x128.png
sips -z 256 256 icon.png --out icon.iconset/[email protected]
sips -z 256 256 icon.png --out icon.iconset/icon_256x256.png
sips -z 512 512 icon.png --out icon.iconset/[email protected]
sips -z 512 512 icon.png --out icon.iconset/icon_512x512.png
sips -z 1024 1024 icon.png --out icon.iconset/[email protected]
iconutil -c icns icon.iconset
cp icon.icns ~/desktop/$DIRNAME.icns
cd ..
rm -rf $DIRNAME
echo "图标已保存至桌面!"
echo "The icon is now on your desktop!"
else
echo "注意:请使用PNG格式的文件!"
echo "Error: Source image format should be PNG!"
fi