Created
October 24, 2018 07:08
-
-
Save hisasann/863f871c2e1a2fdf30eff098459e4e15 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ColorThief = require('color-thief-jimp'); | |
var Jimp = require('jimp'); | |
Jimp.read(imageFilepathOrUrl, (err, sourceImage) => { | |
if (err) { | |
console.error(err); | |
return; | |
} | |
var dominantColor = ColorThief.getColor(sourceImage); | |
// dominantColor = [intRed, intGreen, intBlue] | |
var palette = ColorThief.getPalette(sourceImage, 8); | |
// palette = [ [intRed, intGreen, intBlue], [intRed, intGreen, intBlue], ... ] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment