forked from external-repos/squoosh
Set up decoder infrastructure
This commit is contained in:
16
src/codecs/webp/decoder.ts
Normal file
16
src/codecs/webp/decoder.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { blobToArrayBuffer, imageDataToBitmap } from '../../lib/util';
|
||||
import DecoderWorker from './DecoderWorker';
|
||||
|
||||
export const name = 'WASM WebP Decoder';
|
||||
export const supportedExtensions = ['webp'];
|
||||
export const supportedMimeTypes = ['image/webp'];
|
||||
export async function decode(file: File): Promise<ImageBitmap> {
|
||||
const decoder = await new DecoderWorker();
|
||||
const imageData = await decoder.decode(await blobToArrayBuffer(file));
|
||||
return imageDataToBitmap(imageData);
|
||||
}
|
||||
|
||||
export async function isSupported(): Promise<boolean> {
|
||||
// TODO(@surma): Should we do wasm detection here or something?
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user