This Gist was automatically created by Carbide, a free online programming environment.
Last active
September 15, 2016 06:45
-
-
Save jolks/d002995dda45a52717cd922e59d9e46b to your computer and use it in GitHub Desktop.
untitled
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
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