mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-16 10:39:53 +00:00
Merge v2 codecs (#844)
* wip * doh, whitespace * Updating emscripten, restoring export name * Updating oxipng * Build wasm * Fix oxipng; upgrade Rust * More v2-codec integration * AVIF now working * Non-working JXL * Build hqx with Rust 1.40; refactor build-rust*.sh * Set web target * wp2 wip * wp2 decode options * Better logo height when loading the logo into squoosh * Build oxi * JAKE IS AN IDIOT * wip oxipng * Fixing case sensitive imports * adding log * another log * Abort tasks when compress component removed * Adding progressive option to JXL * Fix bug going to & from original image * Exposing epf in jxl * logs * Bypass initial CSS plugin * Revert "logs" * Adding root * Fix for finding TSC on Windows * Use spawn again * Converting to module paths * Remove spawnP * silly * oops * logs * Fixing glob paths in CSS plugin * Path normalising * Normalise paths for CSS plugin * Normalise again * Use correct func * Adding lossless mode and near lossless (but hidden in UI) * Removing useless comments * Some logging * Update JXL to v0.1. (#846) * Rebuild JXL * Adding slight loss option Co-authored-by: Ingvar Stepanyan <rreverser@google.com> Co-authored-by: Luca Versari <veluca93@gmail.com>
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<script type="module">
|
||||
import webp_enc from './webp_enc.js';
|
||||
|
||||
<!doctype html>
|
||||
<script src='webp_enc.js'></script>
|
||||
<script>
|
||||
async function loadImage(src) {
|
||||
// Load image
|
||||
const img = document.createElement('img');
|
||||
img.src = src;
|
||||
await new Promise((resolve) => (img.onload = resolve));
|
||||
await new Promise(resolve => img.onload = resolve);
|
||||
// Make canvas same size as image
|
||||
const canvas = document.createElement('canvas');
|
||||
[canvas.width, canvas.height] = [img.width, img.height];
|
||||
@@ -16,9 +15,7 @@
|
||||
return ctx.getImageData(0, 0, img.width, img.height);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const module = await webp_enc();
|
||||
|
||||
webp_enc().then(async module => {
|
||||
console.log('Version:', module.version().toString(16));
|
||||
const image = await loadImage('../../example.png');
|
||||
const result = module.encode(image.data, image.width, image.height, {
|
||||
@@ -51,13 +48,11 @@
|
||||
use_sharp_yuv: 0,
|
||||
});
|
||||
console.log('size', result.length);
|
||||
const blob = new Blob([result], { type: 'image/webp' });
|
||||
const blob = new Blob([result], {type: 'image/webp'});
|
||||
|
||||
const blobURL = URL.createObjectURL(blob);
|
||||
const img = document.createElement('img');
|
||||
img.src = blobURL;
|
||||
document.body.appendChild(img);
|
||||
}
|
||||
|
||||
main();
|
||||
});
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user