domcolor

1.0.1 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i domcolor

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

7.61 kB

Total Files

8

Last publish

Collaborators

  • msterpka