Created
March 20, 2019 00:38
Star
You must be signed in to star a gist
Create Icns from image file with shell script
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/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