Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Potentially incorrect test for WebP support #556

Open
padraig-ohiceadha opened this issue Jan 30, 2019 · 1 comment
Open

Potentially incorrect test for WebP support #556

padraig-ohiceadha opened this issue Jan 30, 2019 · 1 comment

Comments

@padraig-ohiceadha
Copy link

The test for image format support (e.g. for WebP) is based on generating a data URL from a canvas element using toDataURL and requesting the output in the image format being requested as if the format is not supported the data url generated will be returned as a PNG instead.
However the supported in practice seems to mean supported by toDataURL, there is nothing in the specs that I can see that toDataURL has to support all of the image formats that the browser supports, and for example Firefox has chosen not to support WebP in toDataURL though they do support WebP images.
See Firefox documentation.
A different approach which appears to be more accurate is to go the other way and take a data URL which is a WebP image and see if the browser can turn it into an image.
Here is a code snippet developed by a Google employee which demonstrates the technique: Gist

@niutech
Copy link

niutech commented Sep 22, 2023

HTML5Test tests canvas export image formats, I've added a test for loading new image formats - try it here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants