Skip to content

mster/domcolor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 values
    • hex: <string> color in hex format
    • count: <integer> the number of pixels are the dominant color
    • total: <integer> the total number of pixels in the image

Example

gopher

{ rgb: [ 208, 182, 152 ], hex: 'd0b698', count: 23210, total: 65536 }

gopher-color