2.3.3 • Published 5 years ago
imagecolor v2.3.3
Installation
project installation
npm install --save imagecolorcmd installation
Inorder to use imagecolor as a command line tool you install it globally by running the following command:
npm install -g imagecolorUsage
Project usage
const {getColor} = require("imagecolor");
const file = { ( absolute || relative ) path to img};
getColor(file).then( (colors) => console.log(colors) ).catch(err=>console.log(err))Example
const {getColor} = require("imagecolor");
const file = "C:\Users\Pictures\image.jpg";
getColor(file).then( (colors) => console.log(colors) ).catch(err=>console.log(err))Output
By default imagecolor extracts the first 10 colors and returns the name,hex,rgb.
[
{ name: 'Bronco', hex: '#a7a195', rgb: 'rgb(167,161,149)' },
{ name: 'Shark', hex: '#232529', rgb: 'rgb(35,37,41)' },
{ name: 'Tasman', hex: '#d8dfd7', rgb: 'rgb(216,223,215)' },
{ name: 'Spicy Mix', hex: '#785140', rgb: 'rgb(120,81,64)' },
{ name: 'Roman Coffee', hex: '#816355', rgb: 'rgb(129,99,85)' },
{ name: 'Fiord', hex: '#3d506c', rgb: 'rgb(61,80,108)' },
{ name: 'Submarine', hex: '#c3cbcc', rgb: 'rgb(195,203,204)' },
{ name: 'Soft Amber', hex: '#d5c5b8', rgb: 'rgb(213,197,184)' },
{ name: 'Fun Blue', hex: '#1f429a', rgb: 'rgb(31,66,154)' }
]Overiding default color count
To overide default colors of 10 , pass a second argument to the getColor function the numbers of colors you want .
getColor(file,5).then( (colors) => console.log(colors) ).catch(err=>console.log(err))Output
[
{ name: 'Bronco', hex: '#a7a195', rgb: 'rgb(167,161,149)' },
{ name: 'Shark', hex: '#232529', rgb: 'rgb(35,37,41)' },
{ name: 'Tasman', hex: '#d8dfd7', rgb: 'rgb(216,223,215)' },
{ name: 'Spicy Mix', hex: '#785140', rgb: 'rgb(120,81,64)' },
{ name: 'Roman Coffee', hex: '#816355', rgb: 'rgb(129,99,85)' }
]Options
| Name | Description | Default value |
|---|---|---|
| file | Path to file | REQUIRED |
| count | numbers of colors to return | 10 |
cmd usage
To use imagecolor as a cmd tool,install globally and run the following command:
getImageColor { ( absolute || relative ) path to img}Example
getImageColor C:\Users\Pictures\image.jpgOutput

Overiding default color count
To overide default colors of 10 pass the count argument of the number of colors you want
getImageColor C:\Users\Pictures\image.jpg 15output
