Apple provides Icon Composer as part of their free developer tools. This is the only officially sanctioned way to create icns files. Most other editors don't support all the possible features. The idea is you create a png file for each size you want, then create an icns file in Icon Composer, and import your various png files into it. Mac icns Icons - Download 225 Free Mac icns icons @ IconArchive. Search more than 600,000 icons for Web & Desktop here.

Mac App Icon Icns
Apple Icon Image
Filename extension
Type codeicns
Uniform Type Identifier (UTI)com.apple.icns
Developed byApple Inc.
Type of format

The Apple Icon Image format is the icon format used in Apple Inc.'s macOS. It supports icons of 16 × 16, 32 × 32, 48 × 48, 128 × 128, 256 × 256, 512 × 512 points at 1x and 2x scale, with both 1- and 8-bitalpha channels and multiple image states (example: open and closed folders). The fixed-size icons can be scaled by the operating system and displayed at any intermediate size.

File structure[edit]

The file format consists of an 8 byte header, followed by any number of icons.

Header[edit]

OffsetSizePurpose
04Magic literal, must be 'icns' (0x69, 0x63, 0x6e, 0x73)
44Length of file, in bytes, msb first

Icon data[edit]

OffsetSizePurpose
04Icon type, see OSType below.
44Length of data, in bytes (including type and length), msb first
8VariableIcon data

Compression[edit]

lead
value
tail
bytes
result
uncompressed
012711281128 bytes
1282551 byte3130 copies

Over time the format has been improved and there is support for compression of some parts of the pixel data. The 32-bit ('is32', 'il32', 'ih32','it32') and ARGB ('ic04', 'ic05') pixel data are often compressed (per channel) with a format similar to PackBits.[1]Some sources mentioned that the OS supports both compressed or uncompressed data chunks.

The following pseudocode decompresses the data:

Example: 02 01 02 02 80 03 81 04 82 05 should decompress to 01 02 02 03 03 03 04 04 04 04 05 05 05 05 05

Icon types[edit]

OSTypeLength (bytes)Size (pixels)Supported OS VersionDescription
ICON128321.032×32 1-bit mono icon
ICN#256326.032×32 1-bit mono icon with 1-bit mask
icm#48166.016×12 1 bit mono icon with 1-bit mask
icm496167.016×12 4 bit icon
icm8192167.016×12 8 bit icon
ics#64 (32 img + 32 mask)166.016×16 1-bit mask
ics4128167.016×16 4-bit icon
ics8256167.016x16 8 bit icon
is32varies (768)168.516×16 24-bit icon
s8mk256168.516x16 8-bit mask
icl4512327.032×32 4-bit icon
icl81,024327.032×32 8-bit icon
il32varies (3,072)328.532x32 24-bit icon
l8mk1,024328.532×32 8-bit mask
ich#288488.548×48 1-bit mask
ich41,152488.548×48 4-bit icon
ich82,304488.548×48 8-bit icon
ih32varies (6,912)488.548×48 24-bit icon
h8mk2,304488.548×48 8-bit mask
it32varies (49,152)12810.0128×128 24-bit icon
t8mk16,38412810.0128×128 8-bit mask
icp4varies1610.716x16 icon in JPEG 2000 or PNG format
icp5varies3210.732x32 icon in JPEG 2000 or PNG format
icp6varies6410.764x64 icon in JPEG 2000 or PNG format
ic07varies12810.7128x128 icon in JPEG 2000 or PNG format
ic08varies25610.5256×256 icon in JPEG 2000 or PNG format
ic09varies51210.5512×512 icon in JPEG 2000 or PNG format
ic10varies102410.71024×1024 in 10.7 (or 512x512@2x 'retina' in 10.8) icon in JPEG 2000 or PNG format
ic11varies3210.816x16@2x 'retina' icon in JPEG 2000 or PNG format
ic12varies6410.832x32@2x 'retina' icon in JPEG 2000 or PNG format
ic13varies25610.8128x128@2x 'retina' icon in JPEG 2000 or PNG format
ic14varies51210.8256x256@2x 'retina' icon in JPEG 2000 or PNG format
ic04varies1616x16 ARGB
ic05varies3232x32 ARGB
icsBvaries3636x36
icsbvaries1818x18
Icons
  • the values inside the brackets () in the length column is the uncompressed length.
  • the ARGB format consists of the ascii values for 'ARGB' and the four compressed channels tightly packed

Other types[edit]

OSTypeLength (bytes)Description
'TOC 'varies'Table of Contents' a list of all image types in the file, and their sizes (added in Mac OS X 10.7)
'icnV'44-byte big endian float - equal to the bundle version number of Icon Composer.app that created to icon
'name'Unknown
'info'259Info binary plist. Usage unknown

Support[edit]

Various image viewers can load *.icns files, and free and open source converters from or to PNG also exist.[2][3]GTK+ can load *.icns resources since 2007.[4] Other tools supporting the format include the Apple Icon Composer and icns Browser, The Iconfactory, and IconBuilder.
MacOS[clarification needed] offers the built-in iconutil command line tool to pack and unpack *.icns files.

Icon

External links[edit]

  • IconFamily – Open source Objective C class to read and write Apple icns files
  • osxiconutils - Command line tools to work with Apple icns files

See also[edit]

  • ICO format on Windows
  • X PixMap format for X11

References[edit]

  1. ^Macintosh Icons
  2. ^'libicns'. SourceForge project icns. 2009. Retrieved August 18, 2016.
  3. ^'png2icns'. Moin Uddin. 2016. Retrieved May 25, 2017.
  4. ^Lyonel Vincent (2007). 'Mac OS X icons for GTK+'. Retrieved August 18, 2016.
Retrieved from 'https://en.wikipedia.org/w/index.php?title=Apple_Icon_Image_format&oldid=976274378'

Developing an application for Mac OS, sooner or later you’ll want to add an icon to it. And Mac OS uses Apple’s own format for application icons - Apple Icon Image format - files with .icns extension. But how does one create such a file?

It is actually not so hard, but there are some tricky moments. I’ll cover those and as a bonus I’ll show you how to use .icns icon in Qt-based application (deadly simple).

There is an out-of-the-box Mac OS tool for such conversion - iconutil (documentation for which is nowhere to find at Apple’s website, so this brief man page is all we have).

However, you cannot just take a random PNG and feed it to iconutil. I mean, you can, but it will give you the following error:

Because iconutil takes only specially named folders. Just how am I supposed to know about that? And it shows similar short and useless error messages for other things it doesn’t like. For example, here’s an output for the situation when files inside iconset folder are not named “properly” or have “wrong” dimensions:

Go figure.

After a set of trials and browsing the internet I found out (hopefully) all the requirements:

  1. First you need to prepare a set of icon pictures and put those into a folder with .iconset “extension”, for example some.iconset;
  2. Pictures from this set should be named in a certain way and have specific dimensions.

Correct dimensions can be found in Apple Guidelines. So it’s 5 different dimensions, but actually 10 “physical” files as each dimension is represented twice (you’ll see why). And these files have to be named according to the following format:

So here’s the full list of proper filenames:

At the same time, I’ve got a commit to my script, and this commit adds more sizes, which supposedly solves some missing size error. I never got such an error, so even though I accepted the commit, I won’t add those changes to the article.

Script to automate the process

Mac App Icon Generator

But that’s rather boring to create all those files manually in some graphics editor, right? So let’s use sips utility (although, I recommend using ImageMagick, as it gives better quality results):

Better, but still - we have to run it 10 times. So let’s write a Python script for that:

The full script is published here.

As an example, I prepared a square picture with a resolution of 2048x2048 and 150 pixel per inch, so there is plenty room to prevent upscaling:

Pass picture path to the script like that:

The script will:

  1. Create a folder ~/Desktop/apple.iconset;
  2. Generate 10 files with different dimensions and save those into that folder;
  3. Call iconutil on this folder and put resulting apple.icns to ~/Desktop/.

Here’s how the final apple.icns looks like in Preview:

So everything from that folder is bundled into one file.

Mac Icon Files

And now the bonus part - how to use .icns as an icon for a Qt-based application.

As I said, it’s deadly simple: put apple.icns into your Qt project folder and add the following line into your-project.pro:

Mac App Icon Format

And that’s it: