Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/skratchdot/color-palette

Get a color palette from a uri using phantomjs and color-thief
https://github.com/skratchdot/color-palette

Last synced: 3 months ago
JSON representation

Get a color palette from a uri using phantomjs and color-thief

Awesome Lists containing this project

README

        

# color-palette

[![Build Status](https://travis-ci.org/skratchdot/color-palette.png?branch=master)](https://travis-ci.org/skratchdot/color-palette)
[![Dependency Status](https://david-dm.org/skratchdot/color-palette.svg)](https://david-dm.org/skratchdot/color-palette)
[![devDependency Status](https://david-dm.org/skratchdot/color-palette/dev-status.svg)](https://david-dm.org/skratchdot/color-palette#info=devDependencies)

## Description

color-palette is a command line tool that uses
[phantomjs](http://phantomjs.org/) and [color-thief](https://github.com/lokesh/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]

## Options

-h, --help output usage information
-v, --version output the version number
-s, --size the target size of the color palette (might return +/- 2)
-q, --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
```bash
$ 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
```bash
$ 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
```bash
$ 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
```bash
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](http://lokeshdhakar.com/projects/color-thief/) - This is the library that
I use to get palette information in the color-palette cli.
- [Pictaculous](http://www.pictaculous.com/) - Upload an image and get it's palatte. They provide
a [free api](http://www.pictaculous.com/api/) as well. At some point I might integrate this API
into the color-palette cli.
- [url2png](https://www.url2png.com/) - 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.