HEIF/HEIC: Apple's Modern Image Standard
High Efficiency Image Format (HEIF) is Apple's answer to JPEG—a container standard that leverages modern video codecs (primarily HEVC/H.265) to achieve 25–50% better compression than JPEG while supporting advanced features like transparency, HDR, depth maps, and multiple images per file. The .heic extension denotes HEIF containing HEVC; .heif is more generic, supporting HEVC or other codecs (AV1, VP9).
HEIF Container Architecture: ISO Base Media File Format
HEIF is built on ISO Base Media File Format (ISOBMFF)—the same box-based structure as MP4. Every HEIF file is composed of boxes (atoms), each with an 8 or 16-byte header:
[Box Size: 4 bytes] [Box Type: 4 bytes (e.g., 'ftyp', 'meta')] [Box Content]
Essential HEIF boxes:
ftyp(File Type): Declares format brand (e.g.,mif1= HEIF with HEVC,heic= HEIC with HEVC), version, and compatibilitymeta(Metadata): Container for image metadata, EXIF, ICC profiles, color space (CICP), and primary image referenceiloc(Item Location): Maps item IDs to data extents (byte ranges where image data lives)iinf(Item Info): Lists all items (images, thumbnails, depth maps) and their propertiesiprp(Item Properties): Stores shared properties (dimensions, colour space, transforms, rotation) referenced by items via property association boxesmdat(Media Data): Raw image/video data (HEVC bitstream, motion data, etc.)pitm(Primary Item): Indicates which item is the primary image (shown by default)infe(Item Info Entry): Describes individual items (name, type, hidden flag)
A simplified HEIF structure:
ftyp (brand: mif1 / heic)
meta
hdlr (handler type: pict)
iloc (item locations)
iinf (item info)
iprp (properties)
ipco (property container)
ispe (image spatial extents: width × height)
colr (colour space)
pixi (pixel information: depth per channel)
irot (rotation: 0°, 90°, 180°, 270°)
rloc (relative location)
clap (clean aperture)
ipma (item property association)
pitm (primary item ID)
mdat (HEVC bitstream / raw pixel data)
HEVC Codec Integration: Video Codec as Image Engine
HEIF's compression strength derives from HEVC (H.265)—a modern video codec originally designed for 4K video. HEVC is packed into HEIF as a bitstream, decoded frame-by-frame to produce still images.
HEVC intra-frame encoding (key to still images):
- CTUs (Coding Tree Units): 64×64 pixel blocks (vs. JPEG's 8×8)
- Intra prediction modes: 35 angular + planar modes (vs. JPEG's simple DC/AC)
- CABAC entropy coding: Context-adaptive arithmetic coding; 30–40% better than JPEG's Huffman
- Transform coding: Varied block sizes (4×4, 8×8, 16×16, 32×32) matched to content
- Loop filtering: Deblocking + SAO (sample adaptive offset) for smoother output
Result: A 2 MP image (~6 MB as JPEG) compresses to ~2–3 MB as HEIC—matching or beating PNG's lossless size while retaining photographic quality.
Transparency and Additional Images: Aux Images and Depth Maps
HEIF supports auxiliary images (aux items) beyond the primary photo:
- Alpha plane: Separate HEVC-encoded transparency mask; stores per-item
auxCbox referencing the alpha - Depth map: Disparity/depth information for focus stacking or 3D reconstruction
- Derived images: Thumbnails, alternative rotations—stored compactly as references to shared CTU data (avoiding duplication)
Example metadata:
<!-- Primary image (ID 1) with associated alpha (ID 2) and depth (ID 3) -->
<primary_item id="1"/>
<auxiliaryImage id="2" type="urn:mpeg:heaac:2015:aux:alpha" for_item_id="1"/>
<auxiliaryImage id="3" type="urn:mpeg:heaac:2015:aux:depth" for_item_id="1"/>
HDR and Colour Space: CICP and ICC
HEIF natively supports HDR (High Dynamic Range) imagery via:
- Colour profile (CICP): Specifies colour primaries (BT.709, DCI-P3, BT.2020), transfer function (SDR linear, PQ, HLG for HDR), and matrix coefficients
- Bit depth: 8-bit SDR, 10-bit HDR (Rec. 2020 / DCI-P3), or 12-bit cinema
- ICC profile: Full colour management (same as TIFF/JPEG)
A HEIC with colr box specifying BT.2020 + PQ transfer signals HDR10 content; display-side tone-mapping converts for SDR displays.
Encoding HEIF: FFmpeg and Apple Tools
FFmpeg with libx265:
# Lossy HEIC at quality 28 (0–51, lower = better; ~JPEG quality)
ffmpeg -i photo.jpg -c:v libx265 -crf 28 \
-tag:v hvc1 -f heic photo.heic
# Lossless HEIC
ffmpeg -i photo.png -c:v libx265 -x265-params lossless=1 \
-tag:v hvc1 photo_lossless.heic
# HDR10 (10-bit HEVC → BT.2020 PQ)
ffmpeg -i hdr_source.exr -c:v libx265 -x265-params crf=28:colorprim=bt2020:transfer=smpte2084 \
photo_hdr.heic
Apple's macOS tools:
# Convert JPEG → HEIC (maintains quality)
sips -s format heic input.jpg --out output.heic
# Batch conversion (Photos app automation via AppleScript)
osascript -e 'tell application "Photos" to export selected to "/path/to/folder" as HEIC'
Python via Pillow (requires system libheif):
from PIL import Image
img = Image.open('photo.jpg')
img.save('output.heic', format='HEIF', quality=28)
Processing HEIF in Workflows
Web delivery:
<picture>
<source srcset="photo.heic" type="image/heic">
<source srcset="photo.webp" type="image/webp">
<img src="photo.jpg" alt="Fallback">
</picture>
Batch conversion (Mac):
for file in *.heic; do
ffmpeg -i "$file" -c:v libx265 -crf 26 "${file%.heic}.jpg"
done
Extracting metadata (Python):
from PIL import Image
from PIL.Image import Exif
img = Image.open('photo.heic')
exif = img.getexif()
print(exif.get(271)) # Camera make
Comparison: HEIF vs JPEG, PNG, AVIF, WEBP
| Aspect | HEIF | JPEG | PNG | AVIF | WEBP |
|---|---|---|---|---|---|
| Codec | HEVC (video) | DCT | Deflate | AV1 (video) | VP8/VP9 (video) |
| Compression | ~50% vs JPEG | Baseline lossy | Lossless | ~30% vs JPEG | ~25% vs JPEG |
| File size | 2–4 MB (2 MP) | 4–6 MB | 8–12 MB | 2–3 MB | 3–4 MB |
| Transparency | Yes (alpha plane) | No | Yes | Yes | Yes |
| HDR | Yes (10/12-bit) | No | No | Yes | No |
| Multiple images | Yes (depth, etc.) | No | No | No | No |
| Browser support | Poor (Safari only) | Universal | Universal | Chrome/Edge only | Chrome/Edge |
| Mobile ecosystem | Native (iOS/macOS) | Universal | Universal | Growing (Android 12+) | Good (most phones) |
| Archival rating | Good (ISOBMFF standard) | Fair (lossy) | Excellent | Unknown (format age) | Unknown (format age) |
When to Choose HEIF
- Apple ecosystem: iOS/macOS native; iPhone photos default to HEIC
- HDR imagery: Professional photography, cinema, gaming assets
- Transparency + compression: Combine alpha channel with HEVC efficiency
- File archival: Deep metadata, auxiliary images, and quality in compact form
- Avoid HEIF if: Web delivery (browser support), Android devices, legacy software (pre-2020)
HEIF represents the future of image storage—combining video codec advances with a flexible container—but adoption remains limited outside Apple's ecosystem.
Related conversions
Most teams that read this guide convert images in one of these directions: