1.0.2 • Published 4 years ago

colortaker v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

🎨 colortaker 🖼️ ➡️ 🖌️🎨

Take an image and print a palette with the most prominent colors.

Install and use the command line

git clone https://github.com/pabrodez/colortaker
cd colortake
npm install

The command takes the arguments: path of your pic, the number of colors in the palette and the palette destination name

For example:

npm run getPalette --- gibson.jpg 4 palette.png

Will give you the example palette.

Or use the module

npm install colortaker
const {printPalette} = require('colortaker')
printPalette('guitar.jpg', 4, 'palette.png')

The Median cut algorithm was implemented as follows:

  1. Take an array of objects containing RGB of each pixel
  2. Find the range of values for each of the three color channel accross pixels in the array
  3. Take the channel with largest range
  4. Find the median value for that channel
  5. Split the pixels in array in two: below the median of that channel and above it
  6. Repeat recursevily until we get N groups
  7. Get average of each group

Credits to:

  • Guitar photo by CÔPAL on Unsplash