项目作者: mster

项目描述 :
Get the dominant color from an image.
高级语言: JavaScript
项目地址: git://github.com/mster/domcolor.git
创建时间: 2020-07-11T23:25:50Z
项目社区:https://github.com/mster/domcolor

开源协议:MIT License

下载


domcolor

Get the dominant color from an image.

Installation

  1. npm install domcolor

Usage

  1. const domcolor = require('domcolor')

Pass path to image file or image file as a buffer.

  1. const dominantColor = await domcolor('path/to/img.jpg')
  2. // Or
  3. 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

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

gopher-color