Promisify emscripten modules & fix webp examples (#817)

This commit is contained in:
Trevor Manz
2020-09-29 19:05:59 -04:00
committed by GitHub
parent 42f9e4aed2
commit 63ac34a662
9 changed files with 23 additions and 36 deletions

View File

@@ -1,8 +1,6 @@
<!doctype html>
<script src='webp_enc.js'></script>
<script>
const module = webp_enc();
async function loadImage(src) {
// Load image
const img = document.createElement('img');
@@ -17,7 +15,7 @@
return ctx.getImageData(0, 0, img.width, img.height);
}
module.onRuntimeInitialized = async _ => {
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, {
@@ -56,5 +54,5 @@
const img = document.createElement('img');
img.src = blobURL;
document.body.appendChild(img);
};
});
</script>