colortaker
v1.0.2
Published
Take a picture and creates a color palette with a number of given colors
Downloads
2
Maintainers
Readme
🎨 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:
- Take an array of objects containing RGB of each pixel
- Find the range of values for each of the three color channel accross pixels in the array
- Take the channel with largest range
- Find the median value for that channel
- Split the pixels in array in two: below the median of that channel and above it
- Repeat recursevily until we get N groups
- Get average of each group
Credits to:
- Guitar photo by CÔPAL on Unsplash