Code Monkey home page Code Monkey logo

color-palette's Introduction

color-palette

Build Status Dependency Status devDependency Status

Description

color-palette is a command line tool that uses phantomjs and color-thief to get a color palette from a website or an image. Any resource that can be opened in phantomjs can be used.

Installation

Install the command line tool globally by running:

npm install -g color-palette

Usage

Usage: color-palette [options] <resource>

Options

-h, --help               output usage information
-v, --version            output the version number
-s, --size <size>        the target size of the color palette (might return +/- 2)
-q, --quality <quality>  the quality of the colors (0 is highest, 10 is default)
-i, --image              add image to output
-o, --output [type]      specify the output type: text, json, or html

Examples

Get a color palette for google.com

$ color-palette http://google.com
      Resource: http://google.com
       Success: true
Dominant Color: #2d2f2e
       Palette: #dcd7d2,#2b2b2b,#2a5fe3,#d94835,#30a28f,#7a7a7a,#049451

Get a color palette for amazon.com, output should be in json format

$ color-palette -o json http://amazon.com
{
  "resource": "http://amazon.com",
  "uri": "http://amazon.com",
  "success": true,
  "dominantColor": "#253a4f",
  "palette": [
    "#24364b",
    "#dadbda",
    "#84454a",
    "#c38f3d",
    "#758b9d",
    "#ad8989",
    "#2ea9c3"
  ]
}

Get an html report for amazon.com and open it

$ color-palette -o html http://amazon.com > output.html & open output.html

# alternative version if you're using OSX w/ homebrew `brew install browser`:
$ color-palette -o html http://amazon.com > output.html | browser

Get a color palette for reddit.com, include a screenshot in the json output

color-palette -i -j http://reddit.com > output.json

NOTE: when including the image switch, the output is very large due to the base64 encoded image data uri

See Also

  • Color Thief - This is the library that I use to get palette information in the color-palette cli.
  • Pictaculous - Upload an image and get it's palatte. They provide a free api as well. At some point I might integrate this API into the color-palette cli.
  • url2png - An API for taking screenshots of websites. Currently, I'm using phantomjs for taking screenshots, but combining the url2png and pictaculous APIs would be an alternative to using color-palette.

License

Copyright (c) 2014 skratchdot
Licensed under the MIT license.

color-palette's People

Contributors

skratchdot avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

joewang704 rempic

color-palette's Issues

Error: Cannot find module 'weak'

#276: $ npm install -g color-palette
-
> [email protected] install /usr/local/lib/node_modules/color-palette/node_modules/phantomjs
> node install.js

PhantomJS detected, but wrong version 2.0.0 @ /usr/local/bin/phantomjs.
Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-macosx.zip
Saving to /var/folders/2b/x43985991b3_t_31n0fc_vq80000gn/T/phantomjs/phantomjs-1.9.8-macosx.zip
Receiving...
  [=====================-------------------] 52% 0.0s
Received 9187K total.
Extracting zip contents
Removing /usr/local/lib/node_modules/color-palette/node_modules/phantomjs/lib/phantom
Copying extracted folder /var/folders/2b/x43985991b3_t_31n0fc_vq80000gn/T/phantomjs/phantomjs-1.9.8-macosx.zip-extract-1442454646117/phantomjs-1.9.8-macosx -> /usr/local/lib/node_modules/color-palette/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /usr/local/lib/node_modules/color-palette/node_modules/phantomjs/lib/phantom/bin/phantomjs

> [email protected] install /usr/local/lib/node_modules/color-palette/node_modules/phantom/node_modules/dnode/node_modules/weak
> node-gyp rebuild



Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.





Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.


gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 69
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:269:23)
gyp ERR! stack     at ChildProcess.emit (events.js:110:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Darwin 14.5.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/color-palette/node_modules/phantom/node_modules/dnode/node_modules/weak
gyp ERR! node -v v0.12.7
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm WARN optional dep failed, continuing [email protected]
/usr/local/bin/color-palette -> /usr/local/lib/node_modules/color-palette/lib/cli.js
[email protected] /usr/local/lib/node_modules/color-palette
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])

#277: $ col
col            colcrt         colldef        color-palette@ colorguard@    colors@        colrm          column

#277: $ color-palette http://google.com
module.js:338
    throw err;
          ^
Error: Cannot find module 'weak'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at new D (/usr/local/lib/node_modules/color-palette/node_modules/phantom/node_modules/dnode/index.js:28:20)
    at module.exports (/usr/local/lib/node_modules/color-palette/node_modules/phantom/node_modules/dnode/index.js:8:12)
    at /usr/local/lib/node_modules/color-palette/node_modules/phantom/phantom.js:159:13
    at Server.handler (/usr/local/lib/node_modules/color-palette/node_modules/phantom/node_modules/shoe/index.js:22:9)
    at Server.emit (events.js:107:17)
    at App.emit (/usr/local/lib/node_modules/color-palette/node_modules/phantom/node_modules/shoe/node_modules/sockjs/lib/sockjs.js:182:27)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.