color-thief | color palette from an image | Runtime Evironment library
kandi X-RAY | color-thief Summary
kandi X-RAY | color-thief Summary
Grab the color palette from an image using just Javascript.Works in the browser and in Node.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Get a palette from an img .
- Validates options
- Create pixel array from image data
- Get a color from an img file
- Load data from img
- Counts the number of RGB values from a string value
- test palette count
- returns an array with all sorts
- sort the order
- Construct a new object
color-thief Key Features
color-thief Examples and Code Snippets
Community Discussions
Trending Discussions on color-thief
QUESTION
Working in Node/Express, I was trying to get the npm package color-thief to grab the dominant color from an image, and it failed because "image given has not completed loading".
The image was, again, local, so it shouldn't have had this particular problem. And besides that, color-thief
returns a promise, and I was using async/await, so it should have waited however long it took for the image to load instead of throwing an error.
Below is my SSCCE code:
...ANSWER
Answered 2020-Jan-31 at 17:57The issue turned out to be that the plugin apparently does not support .webp
files.
It works fine with .jpg
and .png
, though the Documentation (which isn't easy to get to) doesn't explicitly state what file types it does/does not support.
I've submitted a feature request on Github to either add support for webp or update the documentation with an explicit list of supported filetypes, but the author states at the very bottom of his blog regarding the project:
"In the short term I'm not planning on doing any more work on the script."
Just figured I would try to save someone else using this in the future some headache and time
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install color-thief
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page