No browser can encode AVIF via canvas.toBlob — here's how one dev worked around it
A developer building Filewhisk, a browser-based image tool, discovered that canvas.toBlob() silently falls back to PNG when AVIF encoding is requested, rather than throwing an error. This behavior affects all major browsers, including Chrome, Firefox, and Safari, despite Chrome having supported AVIF decoding since version 85. The developer resolved the issue by replacing the native canvas encoder with a WebAssembly-based AVIF encoder from the jSquash library, which ports Google Squoosh's codec to the browser. The multi-threaded version of the encoder was ruled out because it requires cross-origin isolation headers that break third-party ad and analytics scripts. Developers can detect the silent fallback by checking the blob.type property returned by toBlob against the originally requested MIME type.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.



Discussion (0)
Log in to join the discussion and vote.
Log in