HEIF

image/heif

Safe

Magic Bytes

Offset: 4
66 74 79 70 6D 69 66 31

The High Efficiency Image File Format (HEIF) is a container standard developed by the Moving Picture Experts Group (MPEG) for storing individual images and image sequences. It primarily serves as a space-efficient alternative to JPEG for mobile devices, capturing still photos, bursts, and live motion data. While inherently safe, the format relies on complex parsing of media streams, requiring up-to-date software to prevent potential exploits within the decoding process.

Extension

.heif

MIME Type

image/heif

Byte Offset

4

Risk Level

Safe

Validation Code

How to validate .heif files in Python

Python
def is_heif(file_path: str) -> bool:
    """
    Check if file is a valid HEIF by magic bytes.
    Signature offset: 4 bytes
    """
    signature = bytes([0x66, 0x74, 0x79, 0x70, 0x6D, 0x69, 0x66, 0x31])
    with open(file_path, "rb") as f:
        f.seek(4)
        return f.read(8) == signature

How to validate .heif files in Node.js

Node.js
function isHEIF(buffer: Buffer): boolean {
  // Signature offset: 4 bytes
  const signature = Buffer.from([0x66, 0x74, 0x79, 0x70, 0x6D, 0x69, 0x66, 0x31]);
  if (buffer.length < 12) return false;
  return buffer.subarray(4, 12).equals(signature);
}
Go
func IsHEIF(data []byte) bool {
    // Signature offset: 4 bytes
    signature := []byte{0x66, 0x74, 0x79, 0x70, 0x6D, 0x69, 0x66, 0x31}
    if len(data) < 12 {
        return false
    }
    return bytes.Equal(data[4:12], signature)
}

API Endpoint

GET /api/v1/heif
curl https://filesignature.org/api/v1/heif

Related Formats