GithubHelp home page GithubHelp logo

colorific's Introduction

colorific

https://badge.fury.io/py/colorific.png https://travis-ci.org/99designs/colorific.png?branch=master https://pypip.in/d/colorific/badge.png

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 -p 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:

http://media.quietlyamused.org.s3.amazonaws.com/palette/500px-NASA-Ares-logo.svg.png

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:

http://media.quietlyamused.org.s3.amazonaws.com/palette/ares-palette.png

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

ashirviskas avatar dhotson avatar dset0x avatar gkmngrgn avatar larsyencken avatar mtibben avatar pbaehr avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

colorific's Issues

ImportError: cannot import name RGBColor

Is it pyhton-newbie-me missing something for this error ? any help/pointers much appriciated! thx Alex

Its running on debian 6.0 after adding python 2.7 in a virtualenv and says:

webadmin@wartegarten:~/colorific-sandbox$ ./bin/colorific
Traceback (most recent call last):
File "./bin/colorific", line 9, in
load_entry_point('colorific==0.2.1', 'console_scripts', 'colorific')()
File "/home/webadmin/colorific-sandbox/lib/python2.7/site-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/home/webadmin/colorific-sandbox/lib/python2.7/site-packages/pkg_resources.py", line 2363, in load_entry_point
return ep.load()
File "/home/webadmin/colorific-sandbox/lib/python2.7/site-packages/pkg_resources.py", line 2088, in load
entry = import(self.module_name, globals(),globals(), ['name'])
File "/home/webadmin/colorific-sandbox/lib/python2.7/site-packages/colorific.py", line 21, in
from colormath.color_objects import RGBColor
ImportError: cannot import name RGBColor

Could someone explain min_distance, min_prominence, and n_quantized?

I don't see any documentation explaining these things but see them as options when I look at the extrac_colors function in the code. I see that the colors extracted are changing when I set these options, but I have no idea what I'm doing with them or why the colors are changing.

Thanks.

use on webserver

I'm new to python but Is it possible to use colorific in a webserver where instead of streaming the image file in through an echo command it's opened via a url?

Colorific on Windows in a Python script

Hi there,

I am trying to use colorific in a python script running on Windows so I won't be running a binary from the command line or virtual environment as in your examples.

I was able to install it using python setup.py install

My question is how do I use it to operate on an image object such as one returned by:

image = ImageGrab.grab() # take a screenshot

I am running this in a loop and constantly calculate the primary colours of the resultant screenshot image. How do I use the colorific library with the image object in this way?

Note that I could save the images as files and then read them with the script but since it is a real-time application, that would introduce far too much latency.I was hoping for a colorific interface that allows an input that is an image object instead of a file-name.

Thanks!

CalledProcessError when calling colorific using subprocess.check_output

I can do colorific photo.jpg from Terminal just fine, but when I try this in Python, it fails:

colorific_results.append(subprocess.check_output(['colorific', colorific_param]))

Here, colorific_param is just photo_0.jpg. I get:

subprocess.CalledProcessError: Command '['colorific', 'photo_0.jpg']' returned non-zero exit status 1

Any ideas? I am not adamant on using subprocess, but it just felt easier. I can include colorific in my code if I can figure out how to import it. I just want the functionality that I get when normally using the command and I was unsure on which function to call from my script.

The expected end result is a list or dictionary of output (as strings) from several photos in the current directory.

except Exception, e: / SyntaxError: invalid syntax

Hi,

While trying to test some sample images, I got this far:

$ echo j_e6a6aca6.png | python colorific.py 
File "colorific.py", line 48
  except Exception, e:
                  ^
 SyntaxError: invalid syntax

Could it be something with the python version I got here ? My system params:

Linux Arch 3.3.5
Python 3.2.3
python-imaging 1.1.7-4
python-colormath-git 20120512-1
python2-numpy 1.6.1-1

Thanks

pillows update

Can you please update the code to pillows latest version?

Delta E measure

I noticed in palette.py the distance measure used is delta_e_cmc. From what I've read on color theory, wouldn't it be preferable to use delta_e_cie2000 which is a newer (and, possibly, more accurate) measure?

license

I can't find a license for this anywhere. Do you have any terms of its use or plans to add a license file?

test.jpg decoder jpeg not available

I have been playing with Colorific since this morning and I still can't get it to work, am stuck at the decoder not available error message.

(colorific-sandbox)mb@colour:/var/www$ pip install pillow -I
Collecting pillow
Installing collected packages: pillow
Successfully installed pillow-2.8.1
(colorific-sandbox)mb@colour:/var/www$ echo t.jpg | colorific
t.jpg decoder jpeg not available

System Ubuntu 14.04 x64

Conversion to LAB

I may be mistaken but how come you don't convert to the LAB color space as you state in this article? Perhaps, I'm not clear on it but it looks like the only one you're converting to is RGB on line 126.

Segmentation fault: 11

I'm getting this message in the terminal:

Segmentation fault: 11

And a window pops up that says:

Python quit unexpectedly while using the _imaging.so plug-in.

This happens anytime I try to use colorific on the command line:

echo test.png | colorific

I'm running OSX Lion 10.7.3, Python 2.7.1. I've tried compiling from the github source, installing via pip and via easy_install...

Anyone else experiencing this issue or something similar?

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.