Get the dominant color from an image.
Get the dominant color from an image.
npm install domcolor
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)
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
{ rgb: [ 208, 182, 152 ], hex: 'd0b698', count: 23210, total: 65536 }