Skip to content

Instantly share code, notes, and snippets.

@jvarn
Created March 18, 2026 13:56
Show Gist options
  • Select an option

  • Save jvarn/ba2c47047f29b3202c997e8bb4116c9d to your computer and use it in GitHub Desktop.

Select an option

Save jvarn/ba2c47047f29b3202c997e8bb4116c9d to your computer and use it in GitHub Desktop.
Script to convert png icon to macOS icns
#!/bin/bash
# Usage: ./makeicns.sh iconimage.png
#
INPUT="$1"
SOURCE_IMAGE="${INPUT:r}"
mkdir -p "$SOURCE_IMAGE.iconset"
# Resize operations
sips -z 16 16 "$INPUT" --out "$SOURCE_IMAGE.iconset/icon_16x16.png"
sips -z 32 32 "$INPUT" --out "$SOURCE_IMAGE.iconset/icon_16x16@2x.png"
sips -z 32 32 "$INPUT" --out "$SOURCE_IMAGE.iconset/icon_32x32.png"
sips -z 64 64 "$INPUT" --out "$SOURCE_IMAGE.iconset/icon_32x32@2x.png"
sips -z 128 128 "$INPUT" --out "$SOURCE_IMAGE.iconset/icon_128x128.png"
sips -z 256 256 "$INPUT" --out "$SOURCE_IMAGE.iconset/icon_128x128@2x.png"
sips -z 256 256 "$INPUT" --out "$SOURCE_IMAGE.iconset/icon_256x256.png"
sips -z 512 512 "$INPUT" --out "$SOURCE_IMAGE.iconset/icon_256x256@2x.png"
sips -z 512 512 "$INPUT" --out "$SOURCE_IMAGE.iconset/icon_512x512.png" # Fixed filename here
cp "$INPUT" "$SOURCE_IMAGE.iconset/icon_512x512@2x.png"
# Convert folder to .icns file
iconutil -c icns "$SOURCE_IMAGE.iconset" -o "$SOURCE_IMAGE.icns"
# Clean up the temporary iconset folder
rm -rf "$SOURCE_IMAGE.iconset"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment