High Efficiency Image Container
image/heic
Magic Bytes
Offset: 4
66 74 79 70 68 65 69 63
High Efficiency Image Container (HEIC) is a still-image file format based on the HEIF standard developed by the Moving Picture Experts Group (MPEG). It is primarily utilized as the default image storage format on modern Apple devices, capable of storing individual photos, image sequences, and depth data with efficient compression. While the format relies on the secure ISO Base Media File Format, cross-platform compatibility varies, often requiring specific codecs or conversion for viewing on non-Apple systems.
Validation Code
How to validate .heic files in Python
Python
def is_heic(file_path: str) -> bool:
"""
Check if file is a valid HEIC by magic bytes.
Signature offset: 4 bytes
"""
signature = bytes([0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63])
with open(file_path, "rb") as f:
f.seek(4)
return f.read(8) == signature
How to validate .heic files in Node.js
Node.js
function isHEIC(buffer: Buffer): boolean {
// Signature offset: 4 bytes
const signature = Buffer.from([0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63]);
if (buffer.length < 12) return false;
return buffer.subarray(4, 12).equals(signature);
}
Go
func IsHEIC(data []byte) bool {
// Signature offset: 4 bytes
signature := []byte{0x66, 0x74, 0x79, 0x70, 0x68, 0x65, 0x69, 0x63}
if len(data) < 12 {
return false
}
return bytes.Equal(data[4:12], signature)
}
API Endpoint
GET
/api/v1/heic
curl https://filesignature.org/api/v1/heic