Verify a Blob's type before naming an exported image file
An image encoder may return a different format than the one requested, so a filename chosen from the request can be misleading. For canvas exports, toBlob() falls back to PNG when a requested MIME type is unsupported, and its callback receives null if no image can be created. A fallback should be treated as a different output type, and a null result as a failed export. The requested format should be kept separately and compared with the returned Blob's type before choosing a download filename. Applications that require a specific format should show a clear failure rather than silently changing it, while acceptable fallbacks should be explained in the interface.
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