Skip to content

Instantly share code, notes, and snippets.



Created Feb 12, 2018
What would you like to do?
Script to convert png to icns
#!/usr/bin/env bash
# Author: Artem Butusov <>
# Version: 1.0
# Idea:
if [ -z "$source" ]; then
echo "Usage: png2icns <file.png>"
exit 0
if [ ! -e "$source" ]; then
echo "Unable to find file: ${source}"
exit 1
if [ "${source: -4}" != ".png" ]; then
echo "This script could accept only png files with .png extension"
exit 2
iconset="$(basename "${source}" ".png").iconset"
mkdir "${iconset}"
sips -z 16 16 "${source}" --out "${iconset}/icon_16x16.png"
sips -z 32 32 "${source}" --out "${iconset}/icon_16x16@2x.png"
sips -z 32 32 "${source}" --out "${iconset}/icon_32x32.png"
sips -z 64 64 "${source}" --out "${iconset}/icon_32x32@2x.png"
sips -z 128 128 "${source}" --out "${iconset}/icon_128x128.png"
sips -z 256 256 "${source}" --out "${iconset}/icon_128x128@2x.png"
sips -z 256 256 "${source}" --out "${iconset}/icon_256x256.png"
sips -z 512 512 "${source}" --out "${iconset}/icon_256x256@2x.png"
sips -z 512 512 "${source}" --out "${iconset}/icon_512x512.png"
sips -z 1024 1024 "${source}" --out "${iconset}/icon_512x512@2x.png"
iconutil -c icns "$iconset"
rm -R "$iconset"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.