How to export a composed icon as a downloadable canvas image
Answer in brief
Use canvas.toBlob() after drawing is complete. Choose the requested media type, check the actual Blob type and give the downloaded file a matching extension.
Save a labeled folder
Draw the folder and its badge, wait for fonts and images used by the drawing, then request image/png. In the callback, handle a null result before creating a download URL. Open the downloaded file and inspect its pixel dimensions.
Check the exported background
Canvas pixels can be transparent where nothing has been painted. A preview on a white page may hide that fact. Open the saved PNG over a checkerboard to verify the background your user requested. If the export is meant to include an opaque backing, paint it before drawing the icon and label.
Sources
- [1] HTMLCanvasElement: toBlob() method - Web APIs — MDN Web Docs, accessed November 23, 2026
Frequently asked questions
Does CSS control the dimensions of the exported file?
The export uses the canvas bitmap dimensions. Inspect canvas.width and canvas.height when the saved icon appears too small.