rgbcounter
v0.4.1
Published
count up pixel of rgb from image
Downloads
19
Readme
rgbcounter
Usage
get colors by pixels count asc
const { getColors } = require('rgbcounter');
const filepath = 'D:/image.jpg';
const colors = await getColors(filepath);
const mostlyColrs = colors.slice(0, 8);
console.log(mostlyColrs);
/*
[
{color: 'rgb(167,114,132)', count: 360742, amount: 0.2641637375512595},
{color: 'rgb(35,26,31)', count: 301868, amount: 0.22105155243116578},
{color: 'rgb(229,184,193)', count: 48567, amount: 0.035564586994727594},
{color: 'rgb(67,45,56)', count: 23476, amount: 0.017190978324545986},
{color: 'rgb(157,115,127)', count: 14894, amount: 0.01090656121851201},
{color: 'rgb(156,106,119)', count: 13216, amount: 0.009677797305213825},
{color: 'rgb(197,90,130)', count: 8942, amount: 0.006548037492677211},
{color: 'rgb(154,101,145)', count: 7731, amount: 0.005661247803163445}
]
*/
get dominant colors
const { getDominantColors } = require('rgbcounter');
const filepath = 'D:/image.jpg';
const dominantColors = await getDominantColors(filepath);
console.log(dominantColors);
/*
{ color: 'rgb(61,60,60)', count: 17809935, amount: 0.4019618472942949 },
{ color: 'rgb(72,79,135)', count: 12924240, amount: 0.29169401153203633 },
{ color: 'rgb(77,206,212)', count: 3770844, amount: 0.08510617361032526 },
{ color: 'rgb(130,103,134)', count: 3303678, amount: 0.07456245695144433 },
{ color: 'rgb(154,163,174)', count: 2727480, amount: 0.061557939389348885 },
:
*/
Setup
git clone https://github.com/eiurur/rgbcounter.git
cd rgbcounter
npm install
Usage
Run
npm start
Development
npm run dev
Test
npm test