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.49k stars 1.31k forks source link

Support for style="background-image: url('.....') #239

Open mediabuff opened 1 year ago

mediabuff commented 1 year ago

Hi all, does this scenario work ? Does it only work on img tag ?

artrz commented 4 months ago

Just create an img and set the src. Something like:

    const img = document.createElement('img');
    img.src = document.querySelector(querySelector).style.backgroundImage.match(/"(.*?)"/)[1];