Move logic to builtinDecode

This commit is contained in:
Surma
2021-05-24 15:39:38 +01:00
parent 2f00fe2b1b
commit 4033d1c965
2 changed files with 19 additions and 9 deletions

View File

@@ -34,7 +34,6 @@ import { resize } from 'features/processors/resize/client';
import type SnackBarElement from 'shared/custom-els/snack-bar';
import { Arrow, ExpandIcon } from '../icons';
import { generateCliInvocation } from '../util/cli';
import * as WebCodecs from '../util/web-codecs';
export type OutputType = EncoderType | 'identity';
@@ -111,14 +110,8 @@ async function decodeImage(
return await workerBridge.wp2Decode(signal, blob);
}
}
// If none of those work, lets see if Web Codecs API is available
if (await WebCodecs.isTypeSupported(mimeType)) {
try {
return await abortable(signal, WebCodecs.decode(blob, mimeType));
} catch (e) {}
}
// Otherwise fall through and try built-in decoding for a laugh.
return await abortable(signal, builtinDecode(blob));
return await builtinDecode(signal, blob, mimeType);
} catch (err) {
if (err.name === 'AbortError') throw err;
console.log(err);