# libheif WASM — corresponding source & replaceability

LocalPix ships a **separate** libheif WebAssembly binary for on-demand HEIC/HEIF decode on `/heic-to-jpg/`.

## Exact versions we distribute

| Component | Version / pin | Notes |
|-----------|---------------|--------|
| **libheif-js** (npm binding) | **1.23.5** | LGPL-3.0 — https://www.npmjs.com/package/libheif-js / https://github.com/catdad-experiments/libheif-js |
| **libheif** (C++ library) | **v1.23.5** (`413e2a8`) | https://github.com/strukturag/libheif/releases/tag/v1.23.5 |
| **Emscripten build** | catdad-experiments **libheif-emscripten** tag `v1.23.5` | https://github.com/catdad-experiments/libheif-emscripten/releases/tag/v1.23.5 |
| **libde265** | Linked into the upstream emscripten HEIC decoder build (HEVC stills) | https://github.com/strukturag/libde265 (LGPL) |

Shipped object code on this site:

- `/assets/libheif/libheif.js` — Emscripten glue from `libheif-js@1.23.5` `libheif-wasm/libheif.js`, with a **minimal LocalPix patch**: the UMD footer was replaced with `export default` so the browser can `import()` it under our CSP (no `unsafe-eval`). No decoder logic was changed.
- `/assets/libheif/libheif.wasm` — unmodified `libheif-js@1.23.5` `libheif-wasm/libheif.wasm` (~1.4 MB).

## How to obtain corresponding source

1. **npm package (recommended):**  
   `npm pack libheif-js@1.23.5`  
   Contains the same `libheif-wasm/` JS + WASM artifacts.

2. **Upstream libheif tree for v1.23.5:**  
   https://github.com/strukturag/libheif/tree/v1.23.5

3. **Prebuilt emscripten tarball used by libheif-js 1.23.5:**  
   https://github.com/catdad-experiments/libheif-emscripten/releases/download/v1.23.5/libheif.tar.gz  
   (see `scripts/install.js` in https://github.com/catdad-experiments/libheif-js/tree/1.23.5)

4. **Written offer (LGPL):** email **editor@luminesca.net** and ask for the corresponding source of the libheif/libde265 WASM object code we distribute. This offer is valid for **at least three years** from the date you obtained the object code from LocalPix (and for as long as we offer spare parts or customer support for that product model, whichever is longer). We will provide the source on a durable medium or equivalent download at no more than our reasonable cost of physical distribution if applicable.

Full license texts on this site:

- [/licenses/LGPL-3.0.txt](../LGPL-3.0.txt)
- [/licenses/GPL-3.0.txt](../GPL-3.0.txt)

Site NOTICE: [/licenses/](../)

## How to rebuild / replace the WASM

You may replace `/assets/libheif/libheif.wasm` (and the matching glue if APIs change) with a compatible modified build:

1. Build or obtain an Emscripten `libheif` + `libde265` WASM that exports the same JS API as libheif-js (`HeifDecoder`, `HeifImage.display`, etc.), **or** follow the libheif-js install/bundle scripts against a forked libheif-emscripten release.
2. Place your `.wasm` at `/assets/libheif/libheif.wasm` (same origin URL used by `assets/convert.js`).
3. If you change only the WASM and keep the same glue ABI, no JS app changes are required. If the glue changes, update `/assets/libheif/libheif.js` accordingly (keep ESM `export default` if you still load via dynamic `import()`).
4. Redeploy the static site (Cloudflare Pages publish directory `localpix-site/`).

LocalPix application UI code under `assets/convert.js` is separate from the LGPL library and is not required to be GPL’d solely because we dynamically load a replaceable WASM.

## What we intentionally avoid

- **heic2any** and **@saschazar/wasm-heif** (MIT-wrapped embeddings that do not clearly pass through LGPL obligations).
