Icon Composer

In their ongoing efforts to break Mac development tools, Apple disabled and destroyed the rather nice Icon Composer.app because there’s nobody left in-house who could figure out how to generate @2x images (protip: you use double size and rename it!), and now you have to use command-line iconutil with a set of magic filenames and no help.

So I wrote a little shell util, icontool.zsh:

#!/bin/zsh
if [[ $# -ne 2 ]]; then
    echo "Usage: icontool INIMAGE.png OUTFILE.icns"
    exit 1
fi
WORKDIR=$TMP/icontool.iconset
rm -rf "$WORKDIR"
mkdir "$WORKDIR"
sips "$1" --resampleHeightWidth 1024 1024 --out "$WORKDIR/icon_512x512@2x.png"
sips "$1" --resampleHeightWidth 512 512 --out "$WORKDIR/icon_512x512.png"
cp "$WORKDIR/icon_512x512.png" "$WORKDIR/icon_256x256@2x.png"
sips "$1" --resampleHeightWidth 256 256 --out "$WORKDIR/icon_256x256.png"
cp "$WORKDIR/icon_256x256.png" "$WORKDIR/icon_128x128@2x.png"
sips "$1" --resampleHeightWidth 128 128 --out "$WORKDIR/icon_128x128.png"
sips "$1" --resampleHeightWidth 64 64 --out "$WORKDIR/icon_32x32@2x.png"
sips "$1" --resampleHeightWidth 32 32 --out "$WORKDIR/icon_32x32.png"
cp "$WORKDIR/icon_32x32.png" "$WORKDIR/icon_16x16@2x.png"
sips "$1" --resampleHeightWidth 16 16 --out "$WORKDIR/icon_16x16.png"
iconutil --convert icns "$WORKDIR" --output "$2"

Preferably feed it a 1024×1024 input image, it’ll resize all the others; the small sizes might be blurry but it’s good enough for most uses, and you can edit the contents of WORKDIR and run the iconutil line again if you need to.