MacOS icon file
image/icns
Magic Bytes
Offset: 0
69 63 6E 73
The Apple Icon Image format (ICNS) is a proprietary raster image container developed by Apple Inc. specifically for use within the macOS operating system. It allows a single file to store multiple icon representations at varying resolutions and states, ensuring consistent scaling across the Finder, Dock, and other user interface elements. While generally safe to handle as static media, modern software development increasingly favors asset catalogs, reserving this legacy format primarily for application bundles.
Validation Code
How to validate .icns files in Python
Python
def is_icns(file_path: str) -> bool:
"""Check if file is a valid ICNS by magic bytes."""
signature = bytes([0x69, 0x63, 0x6E, 0x73])
with open(file_path, "rb") as f:
return f.read(4) == signature
How to validate .icns files in Node.js
Node.js
function isICNS(buffer: Buffer): boolean {
const signature = Buffer.from([0x69, 0x63, 0x6E, 0x73]);
return buffer.subarray(0, 4).equals(signature);
}
Go
func IsICNS(data []byte) bool {
signature := []byte{0x69, 0x63, 0x6E, 0x73}
if len(data) < 4 {
return false
}
return bytes.Equal(data[:4], signature)
}
API Endpoint
GET
/api/v1/icns
curl https://filesignature.org/api/v1/icns