{
  "schemaVersion": "1.0",
  "canonicalPage": "https://fileformat.co/ext/heic",
  "inspectorUrl": "https://fileformat.co/inspect",
  "spec": {
    "slug": "heic",
    "extension": ".heic",
    "aliases": [
      ".heif"
    ],
    "name": "HEIC (High Efficiency Image Container)",
    "shortName": "HEIC",
    "category": "media-3d",
    "tier": 1,
    "summary": "Apple iOS default camera photo container encapsulating HEVC (H.265) intra-coded image tiles, depth maps, and EXIF metadata inside an ISO Base Media (`ftyp`) box hierarchy.",
    "technicalNotes": "Offset `0x04..0x07` is `'ftyp'`; offset `0x08..0x0B` stores `major_brand` (`'heic'`, `'heix'`, or `'mif1'`). Pixel dimensions reside inside nested `meta -> iprp -> ipco -> ispe` boxes.",
    "mimeTypes": [
      "image/heic",
      "image/heif"
    ],
    "identifiers": {
      "pronomPuid": "fmt/1101",
      "specUrl": "https://mpeg.chiariglione.org/standards/mpeg-h/image-file-format"
    },
    "binarySignature": {
      "endianness": "big",
      "magicBytes": [
        {
          "offset": 4,
          "hex": "66 74 79 70 68 65 69 63",
          "ascii": "ftypheic",
          "description": "ISOBMFF ftyp box with major_brand 'heic' at offset 0x04"
        },
        {
          "offset": 4,
          "hex": "66 74 79 70 6D 69 66 31",
          "ascii": "ftypmif1",
          "description": "Common real-world variant: major_brand 'mif1' (most iPhone photos) with 'heic' in compatible_brands"
        },
        {
          "offset": 4,
          "hex": "66 74 79 70 68 65 69 78",
          "ascii": "ftypheix",
          "description": "Variant: major_brand 'heix' (HEIC sequences without image items)"
        }
      ],
      "containerFamily": "isobmff",
      "headerLayout": [
        {
          "offset": "0x00 - 0x03",
          "byteOffset": 0,
          "byteLength": 4,
          "lengthLabel": "4 B",
          "dataType": "uint32_be",
          "fieldName": "ftyp_size",
          "description": "Byte length of FileTypeBox"
        },
        {
          "offset": "0x04 - 0x07",
          "byteOffset": 4,
          "byteLength": 4,
          "lengthLabel": "4 B",
          "dataType": "char[4]",
          "fieldName": "box_type",
          "description": "ASCII 'ftyp'"
        },
        {
          "offset": "0x08 - 0x0B",
          "byteOffset": 8,
          "byteLength": 4,
          "lengthLabel": "4 B",
          "dataType": "char[4]",
          "fieldName": "major_brand",
          "description": "Primary brand ('heic', 'heix', 'mif1')"
        },
        {
          "offset": "0x10 ..",
          "byteOffset": 16,
          "byteLength": 8,
          "lengthLabel": "4*k B",
          "dataType": "char[4][]",
          "fieldName": "compatible_brands",
          "description": "List of compatible 4CC brands"
        }
      ]
    },
    "securityProfile": {
      "riskLevel": "low",
      "allowsArbitraryCodeOrMacros": false,
      "xxeRisk": false,
      "polyglotPrependRisk": false,
      "pickleDeserializationRisk": false,
      "uploadValidationNotes": "Check both major_brand AND compatible_brands inside ftyp (many valid HEIC photos use major_brand='mif1' with 'heic' in compatible_brands). Strip EXIF GPS boxes before public CDN storage."
    },
    "codeSnippets": {
      "python": "import struct, sys\nwith open(sys.argv[1], \"rb\") as f:\n    sz, btype, brand = struct.unpack(\">I4s4s\", f.read(12))\n    assert btype == b\"ftyp\"\n    print(f\"HEIC ftyp size={sz}B, major_brand={brand.decode('ascii')}\")",
      "typescript": "export async function readHeicBrand(file: File) {\n  const b = new Uint8Array(await file.slice(0, 12).arrayBuffer());\n  const dec = new TextDecoder('ascii');\n  return { box: dec.decode(b.subarray(4, 8)), brand: dec.decode(b.subarray(8, 12)) };\n}",
      "rust": "use std::{fs::File, io::Read};\nfn main() -> std::io::Result<()> {\n    let mut b = [0u8; 12];\n    File::open(std::env::args().nth(1).expect(\"usage: <prog> <file>\"))?.read_exact(&mut b)?;\n    println!(\"box={} brand={}\", String::from_utf8_lossy(&b[4..8]), String::from_utf8_lossy(&b[8..12]));\n    Ok(())\n}",
      "go": "package main\nimport (\"fmt\"; \"io\"; \"os\")\nfunc main() {\n    f, err := os.Open(os.Args[1])\n    if err != nil {\n        fmt.Fprintln(os.Stderr, \"open:\", err)\n        os.Exit(1)\n    }\n    defer f.Close()\n    b := make([]byte, 12)\n    if _, err := io.ReadFull(f, b); err != nil {\n        fmt.Fprintln(os.Stderr, \"read:\", err)\n        os.Exit(1)\n    }\n    fmt.Printf(\"ISOBMFF %s brand=%s\\n\", string(b[4:8]), string(b[8:12]))\n}"
    },
    "relatedFormats": [
      "avif",
      "jpg",
      "webp"
    ],
    "verifiedAt": "2026-11-14T16:09:03Z"
  },
  "samples": [
    {
      "id": "heic-minimal",
      "filename": "minimal-64x64.heic",
      "variant": "minimal",
      "title": "Minimal HEIC Image (64×64, HEVC Main Profile)",
      "description": "Real HEIC encoded by libheif via pillow-heif: ftyp heic, decodable HEVC primary item.",
      "localPath": "/fixtures/v1/heic/minimal-64x64.heic",
      "cdnUrl": "https://fileformat.co/fixtures/v1/heic/minimal-64x64.heic",
      "sizeBytes": 1192,
      "sha256": "a391bd763c27113162242a0e7fbe0bacbe60be3c2e1458b1f0c65d9396b4554c",
      "expectValid": true
    },
    {
      "id": "heic-realistic",
      "filename": "photo-1024x768.heic",
      "variant": "realistic",
      "title": "1024×768 HEIC Photo Fixture",
      "description": "Real HEIF/HEVC still image encoded by libheif at 1024×768 for decoder validation.",
      "localPath": "/fixtures/v1/heic/photo-1024x768.heic",
      "cdnUrl": "https://fileformat.co/fixtures/v1/heic/photo-1024x768.heic",
      "sizeBytes": 183476,
      "sha256": "833313fb74d55f1505032f5cb002d32d727eeae891a646e52311910875cc15c6",
      "expectValid": true
    },
    {
      "id": "heic-edge-case",
      "filename": "truncated-mdat.heic",
      "variant": "edge-case",
      "title": "Truncated HEIC mdat Box",
      "description": "Real HEIC bytes truncated inside the HEVC payload — libheif decoder must raise.",
      "localPath": "/fixtures/v1/heic/truncated-mdat.heic",
      "cdnUrl": "https://fileformat.co/fixtures/v1/heic/truncated-mdat.heic",
      "sizeBytes": 1160,
      "sha256": "f5de0f071b251c113f04832efea09a58ec1fc9908ac083c2f1da96bd7ab46eb8",
      "expectValid": false,
      "edgeCaseTag": "Truncated mdat Box"
    }
  ]
}