Extract colors from images. Supports GIF, JPG, PNG, and even SVG!
npm install get-image-colors --save
This package is intended for use in node environments. It won't work in a browser because it has node-specific dependencies.
const path =const getColors =
You can also use a buffer as an input source.
const fs =const buffer = fsconst getColors =
colors is an array of chroma.js color objects. chroma.js objects have methods that lets you pick the color format you want (RGB hex, HSL, etc), and give you access to powerful color manipulation features:
colors// => ['#FFFFFF', '#123123', '#F0F0F0']colors0// => 'rgb(0,128,128)''
If you don't like promises, you can use node-style callbacks too:
npm installnpm test