domcolor
v1.0.1
Published
Get the dominant color from an image
Downloads
12
Readme
domcolor
Get the dominant color from an image.
Installation
npm install domcolor
Usage
const domcolor = require('domcolor')
Pass path to image file or image file as a buffer.
const dominantColor = await domcolor('path/to/img.jpg')
// Or
const fromBuffer = await domcolor(imageBuffer)
API
domcolor (img)
img
:<string>
|<Buffer>
(Required)The string path to the source image or the source image in buffer form.
Returns:
<Object>
rgb
:<Array>
color RGB valueshex
:<string>
color in hex formatcount
:<integer>
the number of pixels are the dominant colortotal
:<integer>
the total number of pixels in the image
Example
{ rgb: [ 208, 182, 152 ], hex: 'd0b698', count: 23210, total: 65536 }