Skip to content

Instantly share code, notes, and snippets.

@LockeBirdsey
Last active February 2, 2020 11:43
Show Gist options
  • Save LockeBirdsey/0d5cf2b11462ffa1d48905acdb7e1089 to your computer and use it in GitHub Desktop.
Save LockeBirdsey/0d5cf2b11462ffa1d48905acdb7e1089 to your computer and use it in GitHub Desktop.
Convert a PNG to a macOS ICNS file
#!/bin/bash
#The image you want to make into a macOS ICNS file
#Make sure there is an alpha layer or the iconutil command will fail
orig=$1
mkdir icon.iconset
# resize all the images
sips -z 16 16 $orig --out icon.iconset/icon_16x16.png
sips -z 32 32 $orig --out icon.iconset/icon_16x16@2x.png
sips -z 32 32 $orig --out icon.iconset/icon_32x32.png
sips -z 64 64 $orig --out icon.iconset/icon_32x32@2x.png
sips -z 128 128 $orig --out icon.iconset/icon_128x128.png
sips -z 256 256 $orig --out icon.iconset/icon_128x128@2x.png
sips -z 256 256 $orig --out icon.iconset/icon_256x256.png
sips -z 512 512 $orig --out icon.iconset/icon_256x256@2x.png
sips -z 512 512 $orig --out icon.iconset/icon_512x512.png
sips -z 1024 1024 $orig --out icon.iconset/icon_512x512@2x.png
sips -z 1024 1024 $orig --out icon.iconset/icon_1024x1024.png
# create the .icns
iconutil -c icns icon.iconset
# remove the temp folder
rm -R icon.iconset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment