ente/web/docs/heic.md
Manav Rathi 18cc16bcc0
Use preferred casing of Wasm
From webassembly.org

> WebAssembly (abbreviated _Wasm_) is ...
2025-02-03 11:15:00 +05:30

3.0 KiB

HEIC conversion

What

HEIF is a container format.

HEIF can contain HEVC and AV1 data.

  • HEIF can contain one or more images (e.g burst photos)

  • These images can have arbitrary codecs like HEVC, AV1, or even JPEG.

HEVC, aka H.265, is a video codec.

AV1 is a video codec.

  • It is made by a pool of companies, AOM (Alliance for Open Media), as a royalty free alternative to H.265.

AVIF files are HEIF container and AV1 codec.

  • They're supported by all major browsers.

HEIC files are HEIF container and HEVC codec.

  • iPhones and Samsung Galaxy use them as the default.

  • They're only supported by Safari (latest).

FFmpeg

FFmpeg (and its native library, libavcodec) supports HEVC.

FFmpeg, as of 2024, partially supports converting HEIC files

  • "So once this patch is applied, the only unsupported items would be Alpha and Grid (Tiles) for both AVIF and HEIC." (ref)

  • This partial support is not enough. Trying ffmpeg -i 1.heic 1.jpeg on a photo taken by iPhone (iOS 18) gives only a small area of the image. The upstream issue - Support merging HEIC tile grids in ffmpeg - mentions a workaround by combining the grid but that produces a thick gray border on the right and bottom (and the orientation is also not respected).

FFmpeg support would be nice since we already bundle it both in the desktop app and also as a web Wasm build.


libheif + libde265

Every other HEIC converter, binary or library (e.g. ImageMagick, GraphicsMagick, libvips, sharp and wasm-vips), I've seen eventually the uses the combination of libheif (for the HEIF container) + libde265 (for the HEVC decoding), with an option to swap libde265 with libx265 or kvazaar.

Currently our web app uses heic-convert, which provides packaged Wasm builds of libheif + libde265, and the desktop app uses a custom build of vips on Linux and Windows, and Apple's sips on macOS.