How to convert contents of a large Canvas to a JPEG format? I have a large canvas (around 1000x1000 pixels or larger) that I'd like to convert to JPEG formatted data for uploading to a server.
If the image were smaller, I could use canvas.toDataURL('image/jpeg')
, but data URLs have a max size, and my image doesn't fit under that limit.
There is canvas.getImageData() which looks promising, but how to convert that to a JPEG? Is that possible on the client side?
I have tried using canvas.toDataURL(), and it doesn't work for large Canvases. Browsers seem to have max size for dataUrl. For example Chrome gives me data URL data:,
when using a large canvas.