mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-15 01:59:57 +00:00
RawImage -> ImageData; report errors with null
This commit is contained in:
@@ -8,12 +8,9 @@ export async function decode(data: ArrayBuffer): Promise<ImageData> {
|
||||
if (!emscriptenModule) emscriptenModule = initEmscriptenModule(avif_dec, wasmUrl);
|
||||
|
||||
const module = await emscriptenModule;
|
||||
const rawImage = module.decode(data);
|
||||
const result = new ImageData(
|
||||
new Uint8ClampedArray(rawImage.buffer),
|
||||
rawImage.width,
|
||||
rawImage.height,
|
||||
);
|
||||
|
||||
const result = module.decode(data);
|
||||
if (!result) {
|
||||
throw new Error('Decoding error');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user