Skip to content

Instantly share code, notes, and snippets.

@jolks
Last active September 15, 2016 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jolks/d002995dda45a52717cd922e59d9e46b to your computer and use it in GitHub Desktop.
Save jolks/d002995dda45a52717cd922e59d9e46b to your computer and use it in GitHub Desktop.
untitled
import palette from 'palette';
import loadImage from 'blueimp-load-image';
const imageUrl = 'https://i.ytimg.com/vi/tntOCGkgt98/maxresdefault.jpg';
function getColors (file) {
return new Promise ((resolve) => {
loadImage(file, canvas => {
const colors = palette(canvas, 6);
resolve(colors[0]);
}, { canvas: true, maxWidth: 1000 });
});
}
getColors(imageUrl).then(colors => colors);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment