2
I am trying to export to a text file the contents of a canvas
with toDataUrl()
, but I’m getting this mistake:
Domexception: Failed to execute 'toDataURL' on 'Htmlcanvaselement': Tainted canvases may not be Exported
I did some research and discovered that it is not possible to use the toDataUrl
with images of "cross" origins, but the problem is that my image is local.
This is the current code:
const cnv = document.querySelector('canvas');
const ctx = cnv.getContext('2d');
const img = new Image;
img.src='./img/mydraw.png';
ctx.drawImage(img,0,0,300,140,0,0,300,140);
var image = cnv.toDataURL();
var blob = new Blob([image]);
saveAs(blob,'image.txt')
What is the absolute path of the image?
– Luiz Felipe
When you say the image is "local" is localhost, file, some IP, or you tested it on a specific domain?
– Bacco
The image is localhost
– lucas henrique