Created
November 4, 2019 12:06
-
-
Save juliendkim/9153594308d077d4c3998461909afb16 to your computer and use it in GitHub Desktop.
Convert PNG file to ICNS file on Mac
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/bash | |
if [ $# -eq 0 ] | |
then | |
echo 1024x1024 png file to icns converter | |
echo | |
echo Usage: $0 png-filename [output-folder] | |
echo | |
echo Ex : $0 app.png | |
echo Ex : $0 app.png myapp | |
exit | |
fi | |
if [ $# -eq 1 ] | |
then | |
output="${1%.*}" | |
else | |
output=$2 | |
fi | |
mkdir $output.iconset | |
for s in 16 24 32 48 64 96 128 256 512 1024 | |
do | |
for mul in 1 2 3 | |
do | |
if [ $mul -gt 1 ] | |
then | |
add="@${mul}x" | |
else | |
add="" | |
fi | |
if [ $(($s*$mul)) -le 1024 ] | |
then | |
echo sips -z $(($s*$mul)) $(($s*$mul)) $1 --out ${output}.iconset/icon_${s}x${s}${add}.png | |
sips -z $(($s*$mul)) $(($s*$mul)) $1 --out ${output}.iconset/icon_${s}x${s}${add}.png | |
fi | |
done | |
done | |
iconutil -c icns ${output}.iconset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment