Decoding iPhone HEIC photos in Chrome: libheif as WebAssembly, loaded on demand and kept out of the bundle
I'm the developer of MakeQuickWork, a small set of free browser tools. This post is about its HEIC to JPG converter and the two or three things that took longer than the conversion itself. iPhones save photos as HEIC by default. Copy a few of them to a Windows laptop, or try to attach one to a form that only takes .jpg , and you find out how unevenly that format is supported. I wanted a converter…
This article discusses a HEIC to JPG converter tool developed by MakeQuickWork. iPhones save photos as HEIC format by default, which can cause compatibility issues when trying to attach or copy photos to Windows laptops or forms that only accept .jpg format. The developer wanted a converter that runs in the browser without uploading the photos.
Two decode paths exist for Chrome, Edge, and Firefox: first, try the native path and fallback to libheif compiled to WebAssembly if needed. Both paths end on a canvas, where the photo is converted to JPG or PNG format. The decoder isn't bundled in the app, as libheif is LGPL-3.0 licensed, and inlining it into a hashed chunk would be impractical. Instead, the unmodified libheif.js and libheif.wasm are copied to the /vendor/libheif/ directory and loaded from there with a plain script tag.
The converter appends a side effect that iPhone Safari refuses canvases above roughly 16.7 million pixels, scaling any larger photos to stay under ~16 MP. The output does not include EXIF data, such as GPS location, camera model, and date. Additionally, Live Photos and depth or HDR extras are dropped.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.