0

I'm creating an extension to download canvas as an image using the chrome.downloads api, the canvas is tainted so I can't use canvas.toDataUrl() to download the canvas as image, Chrome doesn't allow exporting tainted canvas but it allows downloading the tainted canvas from context-menu, we may use the "save image as" option from the context menu of canvas as can be seen in the following image, but I don't know how.

enter image description here

But I prefer chrome.downloads API, it provides a method called "download" which takes a string argument, but I don't know how to download canvas with the chrome.downloads.download method, So please let me know whether it's possible to download canvas as image using chrome.downloads API.

  • This will help you I guess, https://stackoverflow.com/questions/12796513/html5-canvas-to-png-file – chintuyadavsara Sep 27 '18 at 12:35
  • Thank you for the reply, but like I said "the canvas is tainted so I can't use canvas.toDataUrl() to download the canvas as image" so that link is of no use to me. – Kaleem Ullah Sep 27 '18 at 13:17
  • Not sure there is anything available out of the box, but my extension knowledge is really poor... Maybe it would be part of [pageCapture](https://developer.chrome.com/extensions/pageCapture)? But then you'd have to be able to parse this file in the hope of finding your image... Certainly, it would be part of [tabCapture](https://developer.chrome.com/extensions/tabCapture), here you'd just have to draw one frame of the stream to a canvas (and do some cropping). – Kaiido Sep 27 '18 at 14:12

0 Answers0