Skip to main content
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 -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:

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

Metadata

Release files for colorific 0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for colorific 0.3
File Size Uploaded Provenance
colorific-0.3.tar.gz 8.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for colorific 0.3
File Interpreter ABI Platform
colorific-0.3-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 19.0 kB

Release files / colorific-0.3.tar.gz

Download URL colorific-0.3.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2e47771e8b49d4a71c642c9d2ff6112467cecbc0ba00c6e579fbce8e7a6d265d
BLAKE2b-256 checksum
How to use checksums
7b078d9903f03e01805771cc1735b8e3584fde2b2c9dcb62f51eb0e9aae8ca16
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / colorific-0.3-py2.py3-none-any.whl

Download URL colorific-0.3-py2.py3-none-any.whl
Size 10.4 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
3ac0fb8a8612f3d023e40b2f0f93d36e2bddaa72fb0445a0d73299f19c6c8d0d
BLAKE2b-256 checksum
How to use checksums
a67e21931149d33a9e464c12969795e01b8a7879278f2b19f2327895cb945006
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for colorific 0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page