Skip to content
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

Trying to get it work #23

Closed
onigetoc opened this issue Dec 23, 2013 · 6 comments
Closed

Trying to get it work #23

onigetoc opened this issue Dec 23, 2013 · 6 comments

Comments

@onigetoc
Copy link

I want to get color palette when i click a image. i don't know how to make it work, what should be the value of : sourceImage

image src? all image tag?

The documentation is too minimalist

Nothing work

@simonseddon
Copy link

Really nice work Lokesh but I have to agree with the above. Not only is the documentation too minimal, it is also too convoluted with other javascript (mustache templating, drag & drop, etc.). Just a simple example please.

Also please document that this doesn't work on local filesystem. I can imagine this catching people out and wasting a lot of their time.

I can see that the JS is heavily commented in parts but you can't beat a simple working example.

Do we pass in an element – or an image path? Does it have to an absolute path, etc. etc.

Do we need to wait until all images have loaded (assume yes but please document this).

I'm currently trying to do something really simple (console log a colour) with no success. Namely, I'm getting a Uncaught TypeError: Type error – even after confirming that all images have loaded.

@simonseddon
Copy link

I finally got this to work. My issue was that I was using jQuery to get the image.

var i = $('img');
// Above is fine but you have to then do something like this..
var image = i[0];
// Above properly gets the HTMLImageElement.
var c = colorThief.getColor( image );
console.log(c);
// Above returns an array with three values ( R, G, B ), e.g...
console.log( c[0] );
// .. will return red value.

@althe3rd
Copy link

Thank you so much Simonseddon for the mention on how to grab the img element. I have been banging my head against the keyboard for hours trying to figure out why the script claims I wasn't giving it an image when I selected it using $("img").first(); in jQuery.

@ghost
Copy link

ghost commented Feb 17, 2016

Thanks simonseddon for the last note. I was having a hard time converting the returned R,G,B into Hex. It came to my mind that perhaps the returned value was actually an array, not a string, and I had to iterate through it to get my function going, but didn't came to mind that I could do it this way: c[0],c[1],c[3]. Your little note saved me quite a lot of time!

@zamartz
Copy link

zamartz commented Feb 17, 2016

@pierrebonbon - I created a pull request for HEX conversion here: #78
should give you the gist

@lokesh
Copy link
Owner

lokesh commented Aug 25, 2019

The demo page documentation has been extended with an API table and more examples:
https://lokeshdhakar.com/projects/color-thief/

Hope it helps. I'll continue to flesh out as new questions arrive.

@lokesh lokesh closed this as completed Aug 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants