Files
squoosh/src/codecs/browser-webp/decoder.ts
2018-07-20 10:58:07 +01:00

19 lines
653 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { canDecodeImage, createImageBitmapPolyfill } from '../../lib/util';
export const name = 'Browser WebP Decoder';
export async function decode(blob: Blob): Promise<ImageBitmap> {
return createImageBitmapPolyfill(blob);
}
// tslint:disable-next-line:max-line-length Its a data URL. Whatcha gonna do?
const webpFile = 'data:image/webp;base64,UklGRh4AAABXRUJQVlA4TBEAAAAvAAAAAAfQ//73v/+BiOh/AAA=';
export function isSupported(): Promise<boolean> {
return canDecodeImage(webpFile);
}
const supportedMimeTypes = ['image/webp'];
export function canHandleMimeType(mimeType: string): boolean {
return supportedMimeTypes.includes(mimeType);
}