Skip to content

Instantly share code, notes, and snippets.

@CodeEagle
Created March 20, 2019 00:38
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save CodeEagle/d38c5197cadd2655d3fb2e99001b3da5 to your computer and use it in GitHub Desktop.
Create Icns from image file with shell script
#!/bin/sh
if [[ "$#" -lt 2 ]]; then
echo "usage: icnsutil /path/to/1024x1024image"
exit 1
fi
PIC=$1
PIC_FOLDER="$(dirname "$PIC")"
ICONSET_FOLDER="$PIC_FOLDER/icons.iconset"
ICNS_PATH="$PIC_FOLDER/Icon.icns"
mkdir -p $ICONSET_FOLDER
{
sips -z 16 16 $PIC --out icons.iconset/icon_16x16.png
sips -z 32 32 $PIC --out icons.iconset/icon_16x16@2x.png
sips -z 32 32 $PIC --out icons.iconset/icon_32x32.png
sips -z 64 64 $PIC --out icons.iconset/icon_32x32@2x.png
sips -z 64 64 $PIC --out icons.iconset/icon_64x64.png
sips -z 128 128 $PIC --out icons.iconset/icon_64x64@2x.png
sips -z 128 128 $PIC --out icons.iconset/icon_128x128.png
sips -z 256 256 $PIC --out icons.iconset/icon_128x128@2x.png
sips -z 256 256 $PIC --out icons.iconset/icon_256x256.png
sips -z 512 512 $PIC --out icons.iconset/icon_256x256@2x.png
sips -z 512 512 $PIC --out icons.iconset/icon_512x512.png
sips -z 1024 1024 $PIC --out icons.iconset/icon_512x512@2x.png
} &> /dev/null #for slient output
iconutil -c icns $ICONSET_FOLDER -o $ICNS_PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment