makeicns – Create icns files from the command line

This program lets you convert all kinds of images to Apple's icns
format on the command line. As far as I know, there is no other tool
which does this (tiff2icns doesn't support Leopard's
512x512 icons, and it only supports tiff input, too).

If you prefer a program with a GUI for the same purpose, use
img2icns.

Here's how to use it:

$ ./makeicns
makeicns v1.1 (20090413)
Usage: makeicns [k1=v1] [k2=v2] ...
Keys and values include:
512: Name of input image for 512x512 variant of icon
256: Name of input image for 256x256 variant of icon
128: Name of input image for 128x128 variant of icon
32: Name of input image for 32x32 variant of icon
16: Name of input image for 16x16 variant of icon
in: Name of input image for all variants not having an explicit name
out: Name of output file, defaults to first nonempty input name,
but with icns extension
Examples:
makeicns -512 image.png -32 image.png
Creates image.icns with only a 512x512 and a 32x32 variant.
makeicns -in myfile.jpg -32 otherfile.png -out outfile.icns
Creates outfile.icns with sizes 512, 256, 128, and 16 containing data
from myfile.jpg and with size 32 containing data from otherfile.png.

To convert an icns back to, say, a png either use Preview.app or sips (sips -s format png icon.icns --out icon.png).

Last updated 20090413. Added a workaround around a bug in IconFamily (the icns library this program uses) – it cannot handle NSAlphaNonpremultipliedBitmapFormat images. Alpha masks are now handled correctly.

Original release 20081122.

By the way

If you want to set the icon resource of a file to a given image using the terminal, do the following: