To fix getImageData() error The canvas has been tainted by cross-origin data with JavaScript, we set the img element’s crossOrigin
attribute.
For instance, we write
img.crossOrigin = "Anonymous";
to let us load cross origin images in an img element with JavaScript without getting cross origin errors.
This works for servers that has the Access-Control-Allow-Origin
header set to '*'
.