lokesh / color-thief

Grab the color palette from an image using just Javascript. Works in the browser and in Node.
https://lokeshdhakar.com/projects/color-thief/
MIT License
12.47k stars 1.31k forks source link

The canvas has been tainted by cross-origin data #195

Open itsmnthn opened 4 years ago

itsmnthn commented 4 years ago

Hello,

I am using color thief js locally and using remote image URL to find the color, I am getting this error Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data. I'm getting this error and then not getting colors obviously but I see images loaded on canvas and that is visible on the body.

Though I'm handling error in my code, ColorThief leaves the canvas on the body on an error. please make sure on the error you clear the DOM or memory used while finding color.

It would be better if you put a class or something to identify the canvas created by ColorThief. so it would be possible to tweak ColorThief canvas to hide on error or something.

tuananhl commented 1 year ago

+1