Package Exports
- heic-d-code
- heic-d-code/Heic-D-Code.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (heic-d-code) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Heic-D-Code
- A wasm build of libheif whose only purpose is to decode
.heifimage or the first image of a.heicfor use in a browser. Its size is half of other libraries likeheic2anyorheic-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);
}