New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The canvas has been tainted by cross-origin data. #105
Comments
@petertenhoor did you either get this resolved or find an alternative? |
Hi @zcrowe. I did manage to work around this issue by using a Example with node: https://github.com/Rob--W/cors-anywhere Example with php: https://github.com/softius/php-cross-domain-proxy Good luck! |
@petertenhoor you're a scholar and a gent sir :) Thanks 👍 |
@petertenhoor Even after using Cors Anywhere, i can see in DOM that proxied URL in image tag but it still gives the same error. Do you have an example of the implementation |
It's weird the way cors request work, I also had the same problem, the only way I found is to download images on local ... That's not cool I know, If you use this lib with a nodejs server it will be easy with filesystem but if you are in a web browser (like me I was) I think you have to download the image before with another back-end script |
I've added information around CORS and testing locally in to the FAQ section on the demo page: https://lokeshdhakar.com/projects/color-thief/#faq If there are unanswered questions that are still active around this issue I'll happily reopen. Let me know. Thanks. |
Hi there,
I use color-thief.js on my website and app to generate personalized color skins. The source image used for this is a bannerimage. The url of this bannerimage is retrieved using the YouTube Data API V3 and externally stored. An example of one of this images is:
https://yt3.ggpht.com/-gnl4NYqCQ7c/V01wwjwmNYI/AAAAAAAAAeQ/VFC8dO5UInompWUnQ8eZ250sjJ9MmBCFwCL8B/w2560-fcrop64=1,00005a57ffffa5a8-nd-c0xffffffff-rj-k-no/KickXGamesBANNERV3GROOT.jpg
Using this externally stored image with color-thief.js gave me this error at first:
"Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data."
I managed to fix this by adding the tag 'crossorigin="anonymous"' to my image element. Sadly the server where these images are stored no longer accepts this, so I was forced to remove the crossorigin tag from the image element, which means that the same error is back once again.
Any advice on how to fix this? I'd like to keep using your library.
Best regards,
Peter ten Hoor
The text was updated successfully, but these errors were encountered: