You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: