mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-20 12:38:50 +00:00
Update webp from main branch
This commit is contained in:
@@ -22,5 +22,7 @@ export default async function decode(data: ArrayBuffer): Promise<ImageData> {
|
||||
}
|
||||
|
||||
const module = await emscriptenModule;
|
||||
return module.decode(data);
|
||||
const result = module.decode(data);
|
||||
if (!result) throw new Error('Decoding error');
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ export default async function encode(
|
||||
}
|
||||
|
||||
const module = await emscriptenModule;
|
||||
const resultView = module.encode(data.data, data.width, data.height, options);
|
||||
const result = module.encode(data.data, data.width, data.height, options);
|
||||
if (!result) throw new Error('Encoding error.');
|
||||
// wasm can’t run on SharedArrayBuffers, so we hard-cast to ArrayBuffer.
|
||||
return resultView.buffer as ArrayBuffer;
|
||||
return result.buffer as ArrayBuffer;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user