Skip to content

Instantly share code, notes, and snippets.

@olimart
Created October 19, 2018 13:43
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 olimart/99b8310f37ff3345b4e9217a55694bd4 to your computer and use it in GitHub Desktop.
Save olimart/99b8310f37ff3345b4e9217a55694bd4 to your computer and use it in GitHub Desktop.
color-extract.js
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