New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

node-rgbaster

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-rgbaster

A simple library for extracting dominant colors from images.

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Node-RGBaster

Build Status npm version

A simple library for extracting dominant colors from images for Node.js, which is inspired by RGBaster.

Usage

Usage is simple. Use the path of the image file, then get its dominant color & palette.

var rgbaster = require('node-rgbaster');

var imgpath = '/path/to/image.png';

rgbaster(imgpath).then(res => {
    handleSuccess(res);
}).catch(err => {
    handleError(err);
});

Configuration options

The colors function takes an object as optional second parameter, with the following options:

paletteSize

Type: int Default: 10

Maximum number of palette colors to return. Only the top palette colors will be returned.

exclude

Type: array Default: []

RGB colors to exclude when counting colors. For example to exclude white and black use: [ 'rgb(255,255,255)', 'rgb(0,0,0)' ]

then

Type: function

Function to call after image processing has completed. The function will receive one payload argument with the following structure:

{
    // {string} dominant rgb color
    dominant:  'rgb(0,0,0)',

    // {string} secondary rgb color
    secondary: 'rgb(0,0,1)',

    // {array} list of colors in the image (limited by paletteSize)
    palette:   [ 'rgb(0,0,1)', 'rgb(0,0,2)' ]
}

Full example

var rgbaster = require('node-rgbaster');

var imgpath = '/path/to/image.png';

rgbaster(imgpath, {
    paletteSize: 2
}).then(res => {
    console.log(res);
    /*some of the test results
    {
        dominant: 'rgb(111,108,103)',
        secondary: 'rgb(107,104,99)',
        palette: [ 'rgb(107,104,99)', 'rgb(112,109,104)' ]
    }
    */
}).catch(err => {
    throw err;
});

Promise

This package is built in Promise.

License

MIT

Keywords

canvas

FAQs

Package last updated on 21 Aug 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts