All the encoders that Chrome/Safari/Firefox support out of the box. (#74)

* All the encoders that Chrome/Safari/Firefox support out of the box.

* Typo
This commit is contained in:
Jake Archibald
2018-07-02 19:10:10 +01:00
committed by GitHub
parent 807a76d443
commit 3867448aad
10 changed files with 134 additions and 11 deletions

View File

@@ -0,0 +1,13 @@
import { canvasEncode } from '../../lib/util';
export async function canvasEncodeTest(mimeType: string) {
try {
const blob = await canvasEncode(new ImageData(1, 1), mimeType);
// According to the spec, the blob should be null if the format isn't supported…
if (!blob) return false;
// …but Safari & Firefox fall back to PNG, so we need to check the mime type.
return blob.type === mimeType;
} catch (err) {
return false;
}
}