The file format consists of an 8 byte header, followed by any number of icons.
Header Icon data Icon types • The value inside the parenthesis is the uncompressed length for ARGB and 24-bit RGB icons. • data always starts with a header of four zero-bytes (tested all icns files in macOS 10.15.7 and macOS 11). Usage unknown, the four zero-bytes can be any value and are quietly ignored. • These formats are supported in standalone icns files but do not display properly if used as application icon inside a package.
Image data format • Mono icons with alpha mask can display three colors: white, black, and transparent. • The 4-bit an 8-bit icons use a fixed color palette with 16 colors and 256 colors, respectively. • The 24-bit RGB format consists of the three compressed channels tightly packed (see
Compression). The icon must start with a four-byte header, see footnote above. • The ARGB format consists of the ascii values for 'ARGB' and the four compressed channels tightly packed (see
Compression).
Compatibility • the ARGB fields also accept files in PNG format – but not vice versa, you can not put ARGB images in any of the PNG-only fields (tested on macOS 11). • ARGB images are only supported in macOS 11 and newer – macOS 10.15.7 does not display ARGB images. Yet, even the ARGB keys can be displayed on macOS 10.15 if you set a JPEG 2000 or PNG image (see footnote on usage in app packages above). • The 24-bit RGB icons (, , , ) also allow images in JPEG 2000 and PNG format (tested on macOS 10.15.7 and macOS 11). • The support for newer image types seems to be introduced later than the key field (see previous two points). Therefore, the supported OS version may not be accurate or adjusted based on file format.
Other types • The table of contents is a list of all contained types (4 byte type-name + 4 byte length). • The data for all nested icns files does not contain the icns file-header. So, if you want to save the data to a file you have to prepend the
icns header. == Non-PNG / JPEG2000 element types ==