Apple Icon Image format

The Apple Icon Image format is an 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-bit alpha 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.
As of macOS 11 PNG has become the preferred file formats for macOS custom icons instead.
File structure.
The file format consists of an 8 byte header, followed by any number of icons.
Compression.
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.
Some sources mentioned that the OS supports both compressed or uncompressed data chunks.
The following pseudocode decompresses the data:
While there's compressed data:
 Read one byte as an unsigned number N
 If N < 0x80:
 Output the next (N + 1) bytes
 Else:
 Output the next byte (N - 0x80 + 3) times
Example: should decompress to 
Support.
Various image viewers can load *.icns files, and free and open source converters from or to PNG also exist. GTK+ can load *.icns resources since 2007. Other tools supporting the format include the Apple Icon Composer and icns Browser, The Iconfactory, and IconBuilder.
<br>MacOS offers the built-in codice_1 command line tool to pack and unpack *.icns files.