Created
October 19, 2018 13:43
-
-
Save olimart/99b8310f37ff3345b4e9217a55694bd4 to your computer and use it in GitHub Desktop.
color-extract.js
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
const getColors = require('get-image-colors'); | |
const imageURL = "https://images.unsplash.com/photo-1539806190169-9b25397a73b6" | |
function extractColor(url = imageURL) { | |
const c = here(url) | |
return formattedPalette(c) | |
} | |
function here(url) { | |
getColors(url).then(colors => { | |
//console.log(colors) | |
const r = colors.map(color => color.hex()) | |
return r | |
}) | |
} | |
function formattedPalette(palette) { | |
return { palette: palette } | |
} | |
exports.main = extractColor; | |
// For information only | |
// package.json | |
{ | |
"name": "my-action", | |
"main": "index.js", | |
"dependencies" : { | |
"get-image-colors": "" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment