eg
let img = new Image();
img.addEventListener('load', e => resolve(img));
img.addEventListener('error', e => reject(err));
img.src = url;
In my resolve function I am calling color thief
const colorThief = new ColorThief();
console.log(colorThief.getColor(img));
Receive error
DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
I was assuming that the image is already loaded because I can analyze its height and width etc. But perhaps CORS doesn't kick in until it actually added to the DOM?
Is there a way to extract color info from an img that is not yet added to the DOM?
I have an img object that has already loaded
eg let img = new Image(); img.addEventListener('load', e => resolve(img)); img.addEventListener('error', e => reject(err)); img.src = url;
In my resolve function I am calling color thief const colorThief = new ColorThief(); console.log(colorThief.getColor(img));
Receive error DOMException: Failed to execute 'getImageData' on 'CanvasRenderingContext2D': The canvas has been tainted by cross-origin data.
I was assuming that the image is already loaded because I can analyze its height and width etc. But perhaps CORS doesn't kick in until it actually added to the DOM?
Is there a way to extract color info from an img that is not yet added to the DOM?