+ 1

Canvas is tainted due to CORS

I am using an image I have downloaded which is in the same folder with the rest of my files, I view the page offline, I'm not using a server, and for some reason I get security error when I try to use getImageData(), how do I fix it?

23rd Feb 2021, 9:16 AM
Karak10
Karak10 - avatar
1 Antwort
+ 3
Set image crossOrigin property to "Anonymous" to bypass cors. Eg. var img = new Image(); img.crossOrigin = "Anonymous"; // to bypass cors for imgur image link img.src = "https://i.imgur.com/3oKRio9_d.jpg"; https://code.sololearn.com/WsyBinW9Bpa8/?ref=app
24th Feb 2021, 12:52 PM
Calviղ
Calviղ - avatar