
- Store Emscripten cache inside node_modules/.em_cache. Docker image ships without LTO libs, so Emscripten has to rebuild stdlibs on every build otherwise. - Merge webp_enc + webp_dec build scripts. Core libwebp library is same in both cases, so there's no point in storing and building two copies of it.
25 lines
788 B
HTML
25 lines
788 B
HTML
<!doctype html>
|
|
<script src='webp_dec.js'></script>
|
|
<script>
|
|
const Module = webp_dec();
|
|
|
|
async function loadFile(src) {
|
|
const resp = await fetch(src);
|
|
return await resp.arrayBuffer();
|
|
}
|
|
|
|
Module.onRuntimeInitialized = async _ => {
|
|
console.log('Version:', Module.version().toString(16));
|
|
const image = await loadFile('../../example.webp');
|
|
const result = Module.decode(image);
|
|
const imageData = new ImageData(new Uint8ClampedArray(result.buffer), result.width, result.height);
|
|
Module.free_result();
|
|
const canvas = document.createElement('canvas');
|
|
canvas.width = result.width;
|
|
canvas.height = result.height;
|
|
document.body.appendChild(canvas);
|
|
const ctx = canvas.getContext('2d');
|
|
ctx.putImageData(imageData, 0, 0);
|
|
};
|
|
</script>
|