Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create .icns & .iconset from .png
#!/bin/bash
# Usage: ./icon.sh icon.png
icon=$1
icon_name=${icon%.*}
icon_dir=${icon}.iconset
icon_tmp_path=/tmp/${icon_dir}
mkdir ${icon_tmp_path}
sips -z 16 16 ${icon} --out ${icon_tmp_path}/icon_16x16.png
sips -z 32 32 ${icon} --out ${icon_tmp_path}/icon_16x16@2x.png
sips -z 32 32 ${icon} --out ${icon_tmp_path}/icon_32x32.png
sips -z 64 64 ${icon} --out ${icon_tmp_path}/icon_32x32@2x.png
sips -z 128 128 ${icon} --out ${icon_tmp_path}/icon_128x128.png
sips -z 256 256 ${icon} --out ${icon_tmp_path}/icon_128x128@2x.png
sips -z 256 256 ${icon} --out ${icon_tmp_path}/icon_256x256.png
sips -z 512 512 ${icon} --out ${icon_tmp_path}/icon_256x256@2x.png
sips -z 512 512 ${icon} --out ${icon_tmp_path}/icon_512x512.png
sips -z 1024 1024 ${icon} --out ${icon_tmp_path}/icon_512x512@2x.png
# icns
iconutil -c icns ${icon_tmp_path} -o ./${icon_name}.icns
# iconset
iconutil -c iconset ./${icon_name}.icns -o ${icon_name}.iconset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment