Skip to content

Instantly share code, notes, and snippets.

@krismuniz
Created December 10, 2020 03:20
Show Gist options
  • Save krismuniz/f94ae6b6965b35cbc39d9ff2ad086a63 to your computer and use it in GitHub Desktop.
Save krismuniz/f94ae6b6965b35cbc39d9ff2ad086a63 to your computer and use it in GitHub Desktop.
Generate an iconset and .icns for a given image
# $1 = the path to your png image
imageDir=$(dirname $1);
filename=$(basename $1);
name="${filename%.*}";
# create iconset directory
iconsetDir="${imageDir}/${name}.iconset";
mkdir $iconsetDir;
# generate resized images
sips -z 16 16 $1 --out "$iconsetDir/icon_16x16.png";
sips -z 32 32 $1 --out "$iconsetDir/[email protected]";
sips -z 32 32 $1 --out "$iconsetDir/icon_32x32.png";
sips -z 64 64 $1 --out "$iconsetDir/[email protected]";
sips -z 128 128 $1 --out "$iconsetDir/icon_128x128.png";
sips -z 256 256 $1 --out "$iconsetDir/[email protected]";
sips -z 256 256 $1 --out "$iconsetDir/icon_256x256.png";
sips -z 512 512 $1 --out "$iconsetDir/[email protected]";
sips -z 512 512 $1 --out "$iconsetDir/icon_512x512.png";
sips -z 1024 1024 $1 --out "$iconsetDir/[email protected]";
# create an .icns file
iconutil -c icns $iconsetDir;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment