Skip to content

Instantly share code, notes, and snippets.

@jrmedd
Forked from sergeysova/generate-icns-from-svg.sh
Last active July 17, 2017 13:48
Show Gist options
  • Save jrmedd/430ff5f41b00b3343706ae195569c6c3 to your computer and use it in GitHub Desktop.
Save jrmedd/430ff5f41b00b3343706ae195569c6c3 to your computer and use it in GitHub Desktop.
Generate icns from iconset
#!/bin/bash
# ICNS from PNG
if [[ ! $2 ]]; then
cat<<EOF
Usage:
${0##*/} <input png e.g. "source.png"> <output name e.g. "MyApp">
EOF
exit 1
fi
((err > 0)) && exit 1
mkdir $2.iconset
convert -background none -resize 16x16 -gravity center -extent 16x16 $1 $2.iconset/icon_16x16.png;
convert -background none -resize 32x32 -gravity center -extent 32x32 $1 $2.iconset/[email protected];
convert -background none -resize 32x32 -gravity center -extent 32x32 $1 $2.iconset/icon_32x32.png;
convert -background none -resize 64x64 -gravity center -extent 64x64 $1 $2.iconset/[email protected];
convert -background none -resize 64x64 -gravity center -extent 64x64 $1 $2.iconset/icon_64x64.png;
convert -background none -resize 128x128 -gravity center -extent 128x128 $1 $2.iconset/[email protected];
convert -background none -resize 128x128 -gravity center -extent 128x128 $1 $2.iconset/icon_128x128.png;
convert -background none -resize 256x256 -gravity center -extent 256x256 $1 $2.iconset/[email protected];
convert -background none -resize 256x256 -gravity center -extent 256x256 $1 $2.iconset/icon_256x256.png;
convert -background none -resize 512x512 -gravity center -extent 512x512 $1 $2.iconset/[email protected];
convert -background none -resize 512x512 -gravity center -extent 512x512 $1 $2.iconset/icon_512x512.png;
convert -background none -resize 1024x1024 -gravity center -extent 1024x1024 $1 $2.iconset/[email protected];
iconutil --convert icns $2.iconset
rm -R $2.iconset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment