Apple Icon Image format

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-bit alpha channels and multiple image states (example: open and closed folders).

It is important to note that this header is part of the image data and is not the 4-byte big endian icon element type value (e.g. ic04 or ic05).

The 24-bit RGB (is32, il32, ih32, it32, icp4, icp5) and ARGB (ic04, ic05, icsb) pixel data are compressed (per channel) with a format similar to PackBits.

Here is a GitHub repo with some swift code that appears to pass the test for both encoding and decoding as described here: ByteRunLengthCoder 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 The following pseudocode compresses the data: Example: 01 02 02 03 03 03 04 04 04 04 05 05 05 05 05 should compress to 02 01 02 02 80 03 81 04 82 05 As of macOS 11, there are certain issues / bugs with the file format: Various image viewers can load *.icns files, and free and open source converters from or to PNG also exist.

[9] 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.