Feature test decoding capability

This commit is contained in:
Jake Archibald
2020-08-25 14:13:21 +01:00
parent 549e1fc50a
commit 3f57f9fef1
2 changed files with 3 additions and 1 deletions

View File

@@ -1,14 +1,16 @@
import { builtinDecode, sniffMimeType, canDecodeImage } from '../lib/util';
import Processor from './processor';
import webpDataUrl from 'url-loader!./tiny.webp';
import avifDataUrl from 'url-loader!./tiny.avif';
const webPSupported = canDecodeImage(webpDataUrl);
const avifSupported = canDecodeImage(avifDataUrl);
export async function decodeImage(blob: Blob, processor: Processor): Promise<ImageData> {
const mimeType = await sniffMimeType(blob);
try {
if (mimeType === 'image/avif') {
if (mimeType === 'image/avif' && !(await avifSupported)) {
return await processor.avifDecode(blob);
}
if (mimeType === 'image/webp' && !(await webPSupported)) {

BIN
src/codecs/tiny.avif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B