mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-11 16:26:20 +00:00
19 lines
548 B
HTML
19 lines
548 B
HTML
<!DOCTYPE html>
|
|
<script src="mozjpeg_dec.js"></script>
|
|
<script>
|
|
const module = mozjpeg_dec({
|
|
async onRuntimeInitialized() {
|
|
const image = await fetch("./original.jpg").then(r => r.arrayBuffer());
|
|
const result = this.decode(image);
|
|
|
|
const canvas = document.createElement("canvas");
|
|
canvas.width = result.width;
|
|
canvas.height = result.height;
|
|
// Draw image onto canvas
|
|
const ctx = canvas.getContext("2d");
|
|
ctx.putImageData(result, 0, 0);
|
|
document.body.append(canvas);
|
|
}
|
|
});
|
|
</script>
|