ctj

color-thief-jimp

Grabs the dominant color or a representative color palette from an image with node. Uses javascript and jimp.

Showing:

Popularity

Downloads/wk

174

GitHub Stars

15

Maintenance

Last Commit

3yrs ago

Contributors

14

Package

Dependencies

1

Size (min+gzip)

2.7KB

License

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Color Thief with Jimp for NodeJs

A script for grabbing the color palette from an image. Uses Javascript and the Jimp to make it happen. This fork does NOT use canvas, and is can only used with NodeJs.

Install NodeJs

Install the module via npm

npm install color-thief-jimp --save

And use it:

var ColorThief = require('color-thief-jimp');

How to use

Get the dominant color from an image

var ColorThief = require('color-thief-jimp');
var Jimp = require('jimp');

Jimp.read(imageFilepathOrUrl, (err, sourceImage) => {
  if (err) {
    console.error(err);
    return;
  }

  // getColor(sourceImage[, quality])
  var dominantColor = ColorThief.getColor(sourceImage);
  // dominantColor = [intRed, intGreen, intBlue]
});

Build a color palette from an image

In this example, we build an 8 color palette.

var ColorThief = require('color-thief-jimp');
var Jimp = require('jimp');

Jimp.read(imageFilepathOrUrl, (err, sourceImage) => {
  if (err) {
    console.error(err);
    return;
  }

  // getPalette(sourceImage[, colorCount, quality])
  var palette = ColorThief.getPalette(sourceImage, 8);
  // palette = [ [intRed, intGreen, intBlue], [intRed, intGreen, intBlue], ... ]
});

Changelog

2016-02-26

First release.

Credits

Source code based on color-thief (MIT license) by Lokesh Dhakar lokeshdhakar.com

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100