Dev Tools · 1h ago
canvas.toBlob() Silently Falls Back to PNG on Unsupported Formats
When using canvas.toBlob() to convert images to WebP or AVIF, the method may silently return a PNG if the requested format isn't supported by the browser. This bug can mislead developers into thinking the conversion succeeded, while the output file is actually in a different format. The issue stems from the API's fallback behavior, which doesn't throw an error or warning.
Meridian48 take
This is a classic silent failure that could cause subtle bugs in client-side image processing tools, but it's well-documented and easily mitigated by checking the blob's type.
Read the full reporting
canvas.toBlob() Can Silently Hand You Back a PNG When It Can't Encode What You Asked For →
DEV Community
canvas-apiimage-conversion