lokesh / color-thief

Grab the color palette from an image using just Javascript. Works in the browser and in Node.

Home Page:https://lokeshdhakar.com/projects/color-thief/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

base64 encoded strings as input

mehmetgunacti opened this issue · comments

I have a base64 encoded string : "data:image/png;base64..."

Is there an easy way to get a color palette without having to implement a listener or promise?

If not, please accept this as a feature request. I need something as simple as :

const color = ColorThief.getColor("data:image/png;base64...");
const palette = ColorThief.getPalette("data:image/png;base64...");

I believe this already works? I have the exact same use case and it seems to have worked just fine

I can suggest just preloading string to image tag first: https://hinty.io/devforth/get-dominant-color-from-base64-encoded-string-using-colorthief/

Direct way pointed by @pedsm still not working for me (tried latest version up to this day), library says that the first argument must be an instance of Image, not string.