This is a
playground to test code. It runs a full
Node.js environment and already has all of
npm’s 400,000 packages pre-installed, including
img-to-palette with all
npm packages installed. Try it out:
This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.
Given an image, extracts the color palette using the median-cut algorithm.
Screenshot: Viktor's Juric taken from unsplash
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] .....]
let imgToPalette = require('img-to-palette') let rgbArray = imgToPalette(image) console.log(rgbArray) // [[14, 7, 27], [34, 17, 31] ....] console.log(rgbArray.length) // 8