Lossless HEIC-to-PNG Decoding Without Sideways Rotation or Cloud Uploads
How ISO/IEC 23008-12 Primary Still Selection Works
An Apple HEIC file is not a flat raster stream; it is an ISO Base Media File Format container holding multiple coded HEVC slices, preview thumbnails, depth maps, and TIFF metadata blocks. When you convert a standard iPhone capture to PNG, our parser reads the pitm box inside meta first so the designated hero frame is chosen deterministically even when burst siblings appear earlier in the item directory.
In our verified benchmark input portrait-burst-o6.heic, three 32×24 hvc1 items exist in sequence, yet pitm points to Item ID 2. Naive converters that grab index zero export the wrong frame. After libheif-js decodes the selected HEVC intra slice into canonical straight-alpha RGBA8 memory, our orientation reconciler checks whether container irot or imir properties already transformed the pixels before applying EXIF Orientation 6, producing a clean 24×32 portrait PNG.
- Encoded with @jsquash/png Rust WebAssembly into pure IHDR, IDAT, and IEND chunks.
- Zero eXIf, GPS, MakerNote, or XMP chunks are written into the exported PNG payload.
- Outbound Worker network APIs are locked permanently once WebAssembly modules warm up.
When to Choose Lossless PNG Over Lossy JPEG
Choose PNG whenever downstream editing, UI compositing, OCR ingestion, or archival verification requires zero chroma subsampling and zero generation loss. Because HEVC camera captures use 8-bit or 10-bit YCbCr 4:2:0 coding, transcoding straight to PNG preserves exact reconstructed sRGB code values without introducing 8×8 DCT ringing artifacts.