Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

img-to-palette

pragalakis18MIT1.0.1

Given an image, extracts the color palette.

image, palette, color, canvas, extraction, extract, pallete, palet, quantize, pixels, get, median, cut, thief, jpg, png, gif, rgb

readme

img-to-palette

Given an image, extracts the color palette using the median-cut algorithm.

Screenshot: Viktor's Juric taken from unsplash

Usage

NPM

Takes as an argument an image object <img> and returns an array of 8 RGB colors in the form of [[r, g, b], [r, g, b] .....]

imgToPalette(image)

let imgToPalette = require('img-to-palette')

let rgbArray = imgToPalette(image)
console.log(rgbArray)  // [[14, 7, 27], [34, 17, 31] ....]
console.log(rgbArray.length)  // 8 

License

MIT