Understanding PrimaryItemBox (`pitm`) Semantics in Multi-Image HEIF Files
Why Enumeration Index Zero Is Not Guaranteed to Be Primary
In ISO/IEC 14496-12 and HEIF (ISO/IEC 23008-12), the ItemInfoBox (iinf) lists items by arbitrary integer IDs assigned at muxing time, whereas the mandatory PrimaryItemBox (pitm) declares the single item ID that renderers must treat as the default representation when opening the file in a gallery or browser.
When an iPhone user picks a favorite burst keyframe in Apple Photos, the container can update pitm or attach item-specific cdsc Exif descriptors to that chosen ID without rewriting or reordering preceding mdat slices. In portrait-burst-o6.heic, Item ID 1 sits at index 0, but pitm explicitly selects Item ID 2 at index 1 and binds Exif Item 4 to ID 2 via cdsc.
- Parses both 16-bit (version 0) and 32-bit (version 1) pitm item_ID fields.
- Cross-checks libheif is_primary() handle flags against raw pitm header bytes.
- Highlights metadata cdsc bindings so you see which item owns the EXIF block.
Debugging Ingestion Bugs in Custom DAM and Thumbnail Pipelines
If your digital asset management script extracts index 0 via ffmpeg stream mapping instead of querying the HEIF primary item, users see rejected blink frames or unrotated raw slices. Use this inspector to confirm exact pitm IDs before configuring automated server or mobile ingestion.