Extract colors from images. Supports GIF, JPG, PNG, and even SVG!
npm install image2colors --save
const image2colors =
colors is an array of custom objects, with occurrence (wegiht) and 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']colors// => [1700, 64, 23]colors0color;// => 'rgb(0,128,128)''
To extract palettes from SVG files, a PNG copy is created on the fly using svg2png, which depends on PhantomJS. PhantomJS can be installed as a local node module, unlike canvas which has external dependencies.
npm installnpm test
The original "get-image-colors" module comes from zeke And great thanks giving for all the developers of the required dependencies.