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.62k stars 1.32k forks source link

Error with entirely white image. #72

Open dfc1883 opened 9 years ago

dfc1883 commented 9 years ago

I've used your color-thief successfully apart from uploading an entirely white image. just a simple 100x100.jpg that is completely #ffffff

I couldn't get it working in my script - it has the error

Uncaught TypeError: Cannot read property '0' of null (which refers to the following line marked ****)

ColorThief.prototype.getColor = function(sourceImage, quality) { var palette = this.getPalette(sourceImage, 5, quality); var dominantColor = palette[0];**** return dominantColor; };

I tried to figure it out, but then decided to try it in your live demo at http://lokeshdhakar.com/projects/color-thief/

and it breaks that too.

ksubileau commented 9 years ago

Dup of #40, #58, #62 and #49. It's a "feature", see my comment on #49.