Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ncou/color-thief-raw

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Color Thief for NodeJs

This fork allows white color and uses 3 or 4 channels raw data for input

How to use

Get the dominant color from an image

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

// getColor(sourceImage[, quality])
// sourceImage = {
//   data: [...], // 3 or 4 channels raw data
//   info: {
//     width: imageWidth,
//     height: imageHeight,
//     channels: numberOfChannels
//   }
// }
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-raw');

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

Credits

Source code based on

color-thief (MIT license) by Lokesh Dhakar lokeshdhakar.com

color-thief-jimp (MIT license) by Jean-Matthieu DECHRISTÉ

About

Grabs the dominant color or a representative color palette from an image with node.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%