- From: Ashley Gullen <ashley@scirra.com>
- Date: Wed, 24 Jun 2015 13:48:32 +0100
- To: "public-webapps@w3.org" <public-webapps@w3.org>
- Message-ID: <CAABs73jDxf+kPgsZZoHjWAFnXnC6Ly5dKe+jKmDXABD6SvQLGA@mail.gmail.com>
While drafting https://www.scirra.com/labs/specs/imagebitmap-conversion-extensions.html I realised that there is no way to tell in JS what image formats the browser can decode (with Image or ImageBitmap objects) or encode (with canvas toDataURL()/toBlob() or the ImageBitmap.toBlob() method I was proposing). HTMLMediaElement.canPlayType() can give an indication if an audio or video format can be decoded. MediaRecorder.canRecordMimeType() can give an indication if an audio or video format can be encoded. Should we not have the same for images? For example there are a number of image formats beyond PNG and JPEG which some browsers support, such as: - JPEG 2000 (Safari) - JPEG XR (IE/Edge) - WebP (Blink) - APNG (Firefox, Safari) - any other future formats Most client-side detection I've seen involves either trying to load a data URI included in the source, or using canvas' toDataURL() and seeing if the resulting data URI includes the expected MIME type. I think there should be methods on some object (be it Image, ImageBitmap or Canvas) for: - canDecodeType(): indicate if an image format can be encoded by Image/ImageBitmap objects - canEncodeType(): indicate if an image format can be encoded by Canvas toDataURL/toBlob (or my proposed ImageBitmap.toBlob()) Thoughts?
Received on Wednesday, 24 June 2015 12:49:00 UTC