forked from external-repos/squoosh
Feature test decoding capability
This commit is contained in:
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user