Giter VIP home page Giter VIP logo

colorific's Introduction

colorific

image

image

image

Image palette detection in Python modelled after Paul Annesley's color detector in PHP. colorific determines what the most important colors used in your image are, and if one of them is a background color.

by Dennis Hotson & Lars Yencken

Installation

The easiest way to install colorific is with Python's pip and virtualenv:

$ virtualenv colorific-sandbox
$ ./colorific-sandbox/bin/pip install colorific

You can then run colorific from ./colorific-sandbox/bin/colorific.

Usage

colorific is meant to run in a streaming manner. You can run it on a single image by echo'ing in the image:

$ echo myimage.png | colorific
myimage.png #3e453f,#2ea3b7,#bee6ea,#51544c,#373d38 #ffffff

Each input line should be a filename. Each output line will be a tab-delimited string containing the filename, major colors in order, and (optionally) a detected background color.

To run on an entire directory tree of images:

$ find . -name '*.jpg' | colorific

For a small amount of images, colorific can also be invoked with the image file names provided as arguments:

$ colorific myimage.png
myimage.png #3e453f,#2ea3b7,#bee6ea,#51544c,#373d38 #ffffff

You can also get a rendered palette with hex codes for each image with the -o argument:

$ colorific -o myimage.png
myimage.png #3e453f,#2ea3b7,#bee6ea,#51544c,#373d38 #ffffff
$ ls
myimage.png  myimage_palette.png

You can use an experimental multiprocessing mode with the -n argument. For example, to run the same example using 8 processes:

$ find . -name '*.jpg' | colorific -p 8

You can also get usage information by running colorific --help.

Example

Here's a concrete example of use. This is the NASA Ares logo:

image

Let's run palette detection on it:

$ echo 500px-NASA-Ares-logo.svg.png | colorific
500px-NASA-Ares-logo.svg.png  #0065b9,#bbd6ec,#ff0000

These correspond to the colors:

image

Note that black and white have been stripped away, and minor colors introduced through antialiasing are not present.

Changelog

0.3.0

  • Python 3 support
  • Bump colormath version to 2.0.2

0.2.2

  • Use the recent 1.7.8 Pillow release instead of the master branch
  • Pin the colormath to 1.0.9 or earlier, given API changes in newer code

0.2.1

  • Project renamed to colorific
  • Tuning around quantization and color merging
  • Use patched Pillow dependency to avoid segmentation fault bug
  • Support for outputting a palette file per image

0.2.0

  • Tuning around background color, similarity thresholds for merging, and minimum saturation
  • Make an importable module

0.1.0

  • Functional palette detection

colorific's People

Contributors

larsyencken avatar gkmngrgn avatar pbaehr avatar dhotson avatar dset0x avatar

Watchers

James Cloos avatar k9-dev avatar

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.