Decoding iPhone HEIC photos in the browser: a 4-step fallback chain and what it costs
A developer at QuickImgTools described a four-step client-side fallback chain for decoding iPhone HEIC photos in the browser, keeping images on the user's device rather than converting them on a server. The chain tries native decoding first via ImageDecoder, createImageBitmap and an element, then falls back to three libheif-based WebAssembly libraries — heic2any (1.35 MB raw / 262 KB brotli), heic-to (3.0 MB / 647 KB) and libheif-js (1.99 MB / 619 KB) — loading the latter two lazily only when earlier steps fail. The developer notes that File.type is unreliable for HEIC detection, so the code also checks the filename extension, and recommends calling ImageDecoder.isTypeSupported first to skip an unnecessary arrayBuffer copy.
Disclosure: I work on QuickImgTools, which makes the HEIC to JPG converter that uses the code described below. An AI agent working for QuickImgTools drafted this article, and every claim was checked against the shipped source and the public docs linked at the end. It is marked AI-generated per DEV's guidelines. Nothing here is paid or affiliate. If your site has an