Making ICNS files

Volume 7, Issue 2; 05 Jan 2023

TIL: how to construct an ICNS file from a bunch of PNGs on MacOS.

MacOS uses an “ICNS” file to store icons in a variety of sizes and resolutions. Wikipedia’s description of th Apple Icon Image format says “asset catalogs” are preferred these days, so maybe there’ll be a TIL post about that some day. For the moment, I need an ICNS file (for the drive icons associated with a DMG file, in case you’re wondering).

Construct images in the resolutions you need. I started with some blank icons that were 16, 32, 256, 512, and 1024In fact, the ICNS file is apparently supposed to have 128 pixel versions as well, but I just let ImageMagick scale the 256 pixel version. Had I planned ahead, I could probably have just made one version at 1024 pixels and let ImageMagick scale them all. I didn’t plan ahead. pixels square.

Make an “.iconset” directory, I created DriveIcons.iconset.

Use ImageMagick’s convert (or any tool you like, I suppose) to make the files. For the drive icons, I need 16x16, 16x16@2x (that’s 32x32), 32x32, 32x32@2x, 128x128, 128x128@2x, 256x256, 256x256@2x, 512x512, and 512x512@2x sizes. Your application might need different ones, but the technique is the same.

convert -geometry 16x16     Disk_16x16.png     DriveIcons.iconset/icon_16x16.png
convert -geometry 32x32     Disk_32x32.png     DriveIcons.iconset/icon_16x16@2x.png
convert -geometry 32x32     Disk_32x32.png     DriveIcons.iconset/icon_32x32.png
convert -geometry 64x64     Disk_256x256.png   DriveIcons.iconset/icon_32x32@2x.png
convert -geometry 128x128   Disk_256x256.png   DriveIcons.iconset/icon_128x128.png
convert -geometry 256x256   Disk_256x256.png   DriveIcons.iconset/icon_128x128@2x.png
convert -geometry 256x256   Disk_256x256.png   DriveIcons.iconset/icon_256x256.png
convert -geometry 512x512   Disk_512x512.png   DriveIcons.iconset/icon_256x256@2x.png
convert -geometry 512x512   Disk_512x512.png   DriveIcons.iconset/icon_512x512.png
convert -geometry 1024x1024 Disk_1024x1024.png DriveIcons.iconset/icon_512x512@2x.png

It’s obviously kind of pointless to scale images to their current size, but there was less thinking involved this way and I’m going to script it all anyhow.

Next, use iconutil to make the actual ICNS file:

iconutil -c icns DriveIcons.iconset

Of particular importance, the files in the icon set directory have to be named icon_…. I tried naming them Disk_… the first time and got an error.

After you’ve created the ICNS file, you can delete the .iconset directory.


Please provide your name and email address. Your email address will not be displayed and I won’t spam you, I promise. Your name and a link to your web address, if you provide one, will be displayed.

Your name:

Your email:


Do you comprehend the words on this page? (Please demonstrate that you aren't a mindless, screen-scraping robot.)

What is five minus five?   (e.g. six plus two is 8)

Enter your comment in the box below. You may style your comment with the CommonMark flavor of Markdown.

All comments are moderated. I don’t promise to preserve all of your formatting and I reserve the right to remove comments for any reason.