The canvas has been tainted by cross-origin data local image
问题 This question has been asked a lot, but I just don't understand why this is happening to me. Basically, I have a canvas, and an image, and when I try to do this: var canvas = document.getElementById('somecanvas'); var ctx = canvas.getContext('2d'); var someimage = document.createElement('img'); someimage.setAttribute('src', 'img/someimage.png'); someimage.onload = function(){ ctx.drawImage(someimage, 0, 0, canvas.width, canvas.height); data = ctx.getImageData(0,0,canvas.width,canvas.height);