-
-
Save lincerely/79bb419ecfc4595ead038b0727e7ad1a to your computer and use it in GitHub Desktop.
covert svg to icns (with imagemagick)
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
#!/usr/bin/env bash | |
# ref: https://gist.github.com/zlbruce/883605a635df8d5964bab11ed75e46ad | |
if [ $# -ne 1 ]; then | |
echo "Usage: svg2icns filename.svg" | |
exit 1 | |
fi | |
filename="$1" | |
name=${filename%.*} | |
dest="$name".iconset | |
mkdir "$dest" | |
# increase density to remove blur | |
# ref: https://stackoverflow.com/a/12690135 | |
convert -background none -density 1200 -resize '!16x16' "$1" "$dest/icon_16x16.png" | |
convert -background none -density 1200 -resize '!32x32' "$1" "$dest/icon_16x16@2x.png" | |
convert -background none -density 1200 -resize '!64x64' "$1" "$dest/icon_32x32@2x.png" | |
convert -background none -density 1200 -resize '!128x128' "$1" "$dest/icon_128x128.png" | |
convert -background none -density 1200 -resize '!256x256' "$1" "$dest/icon_128x128@2x.png" | |
convert -background none -density 1200 -resize '!512x512' "$1" "$dest/icon_256x256@2x.png" | |
convert -background none -density 1200 -resize '!1024x1024' "$1" "$dest/icon_512x512@2x.png" | |
cp "$dest/icon_16x16@2x.png" "$dest/icon_32x32.png" | |
cp "$dest/icon_128x128@2x.png" "$dest/icon_256x256.png" | |
cp "$dest/icon_256x256@2x.png" "$dest/icon_512x512.png" | |
iconutil -c icns "$dest" | |
rm -r "$dest" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment