Skip to content

A wasm build of libheif whose only purpose is to decode `.heif` image or the first image of a `.heic` for use in a browser.

License

Notifications You must be signed in to change notification settings

msqr1/Heic-D-Code

Repository files navigation

Heic-D-Code

  • A wasm build of libheif whose only purpose is to decode .heif image or the first image of a .heic for use in a browser. Its size is half of other libraries like heic2any or heic-to.
  • Used in SnapFridge
  • Version: libde265 1.0.16, libheif 1.20.1, emscripten 4.0.12

Building instruction (from scratch)

Try to use Ninja

git clone --depth 1 https://github.com/msqr1/Heic-D-Code &&
cd Heic-D-Code &&
cmake -P Setup.cmake &&
source emsdk/emsdk_env.sh &&
mkdir build &&
cd build &&
emcmake cmake .. -DCMAKE_BUILD_TYPE=Release &&
cmake --build . --config Release -j$(nproc)

Usage

import initDecoder from "./Heic-D-Code.js";

const decoder = await initDecoder();
const canvas = document.createElement("canvas");
const context = canvas.getContext("2d");

try {
  const heic = await fetch("example.heic");
  const inData = await heic.bytes();
  const decodeOutput = decoder.decode(inData);
  canvas.width = width;
  canvas.height = height;
  ctx.putImageData(new ImageData(...decodeOutput), 0, 0);
} catch (e) {
  console.log(e);
}

About

A wasm build of libheif whose only purpose is to decode `.heif` image or the first image of a `.heic` for use in a browser.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published