Freshchris Freshchris - 7 months ago 46
HTML Question

Download Canvas as Image without .toDataUrl()

Is it possible to download the (edited) Image of a Canvas Element in

HTML
without using the
.toDataUrl()
function? I tested some frameworks but they still use this function.

Answer

In newer browsers, you can get MUCH larger images and faster performance with the async method canvas.toBlob(callback, mimeType, qualityArgument);

see the mdc article for details and compat (basically IE10+)

the blob doesn't have the same size limits that dataURL realistically face in many browsers and devices, so where supported, it leads to a much better user experience.

if you later want to turn the blob into a dataURL, use FileReader.readAsDataURL(blob)