I want to load a png-image into a canvas get the base64-string from it.
This is my code:
pic2b64: function () {
var canvas = document.createElement("canvas");
var ctx = canvas.getContext('2d');
var img = new Image();
img.src = "http://pngimg.com/uploads/dog/dog_PNG50346.png";
img.addEventListener('load', e => {
ctx.drawImage(img, 0, 0);
img.crossOrigin = "Anonymous";
var dataURL = canvas.toDataURL("image/png");
})
},
When I want to execute my code, I get the following error in the browser:
Failed to execute
'toDataURL'
on'HTMLCanvasElement'
: Tainted canvases may not be exported.
(programmed in javascript, executed in browser)