I am trying to merge two pictures and convert them to the canvas, then to PNG file. But it gives me error that says:
script.js:56 Uncaught SecurityError: Failed to execute 'toDataURL' on 'HTMLCanvasElement': Tainted canvases may not be exported.
What should I do to fix this? Here is my code:
var merged = document.getElementById("myCanvas");
var ctx = merged.getContext("2d");
var img1 = document.getElementById("banner");
var img2 = document.getElementById("myPro");
ctx.drawImage(img2,-50,-20);
ctx.drawImage(img1,0,260);
var profile = new Image();
profile.setAttribute('crossOrigin', 'anonymous');
profile.src = merged.toDataURL();
Aucun commentaire:
Enregistrer un commentaire