A script for grabbing the color palette from an image. Uses Javascript and the canvas tag to make it happen.
See a Demo | Read more on my blog
npm install --save colorthief
If you see an error during install, it is probably related to the system dependencies required by the 'node-canvas' dependency. Follow the steps posted on their repo: https://github.com/Automattic/node-canvas/tree/v1.x#installation
var colorThief = new ColorThief();
colorThief.getColor(sourceImage);getColor(sourceImage[, quality])
returns [num, num, num]In this example, we build an 8 color palette.
var colorThief = new ColorThief();
colorThief.getPalette(sourceImage, 8);getPalette(sourceImage[, colorCount, quality])
returns [ [num, num, num], [num, num, num], ... ]