• This repository has been archived on 30/May/2023
  • Stars
    star
    699
  • Rank 64,759 (Top 2 %)
  • Language
    Python
  • License
    ISC License
  • Created over 12 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Automatic color palette detection

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

More Repositories

1

gqlgen

go generate based graphql server library
Go
9,940
star
2

aws-vault

A vault for securely storing and accessing AWS credentials in development environments
Go
8,472
star
3

keyring

Go library providing a uniform interface across a range of secure credential stores
Go
579
star
4

iamy

A cli tool for importing and exporting AWS IAM configuration to YAML files
Go
238
star
5

phumbor

A minimal PHP helper for Thumbor
PHP
120
star
6

gqlgen-contrib

Add-ons for gqlgen
Go
85
star
7

cmdstalk

beanstalkd broker; run jobs as unix commands.
Go
73
star
8

aws-ecr-gc

Garbage collector for Amazon ECR docker registry
Go
48
star
9

http-signatures-php

Sign and verify PSR-7 HTTP messages in PHP.
PHP
44
star
10

goodies

A grab-bag of useful Go helper libraries
Go
32
star
11

ergo

A lightweight php5 library for request/response routing, controllers and http interaction.
PHP
29
star
12

httpsignatures-go

A golang http-signatures library
Go
28
star
13

clouddetect

Go package for resolving IP addresses back to published cloud provider public ranges
Go
27
star
14

gqlgen-workshop

Source for a workshop on generating GraphQL servers with gqlgen
Go
24
star
15

thumbor_botornado

Thumbor S3 backend based on botornado async client.
Python
21
star
16

http-signatures-ruby

Sign and verify HTTP messages in Ruby.
Ruby
21
star
17

basicauth-go

HTTP basic auth middleware for golang
Go
19
star
18

telemetry

Golang application monitoring middleware
Go
18
star
19

http-signatures-guzzlehttp

Guzzle 6 support for 99designs http-signatures library
PHP
12
star
20

simpletest

Unit testing, mock objects and web testing framework for PHP built around test cases.
PHP
11
star
21

ecs-upload-task

Upload an ecs task definition and optionally deploy it
Go
11
star
22

httpforwarder

Asynchronously forward HTTP requests
Go
10
star
23

protobuf-playground

Playground and generated docs for Protobuf files
TypeScript
8
star
24

php-desk

PHP client for desk.com API
PHP
7
star
25

dddk

Datadog Development Kit
TypeScript
7
star
26

smartling

Smartling is a library and cli tool for managing Smartling projects
Go
6
star
27

capistrano-rightscale

A Capistrano extension that maps Rightscale tags to Roles
Ruby
4
star
28

rightsignature-php

PHP wrapper around the RightSignature API
PHP
4
star
29

relax

A library for consuming simple REST services in PHP5.
PHP
3
star
30

silex-assets

An asset pipeline for Silex orchestrated by make
PHP
3
star
31

sera

A library for queuing and executing php5 tasks
PHP
3
star
32

http-signatures-guzzle

Guzzle 3 support for 99designs http-signatures library
PHP
2
star
33

cliph

A PHP5.3 library for testable CLI applications
PHP
2
star
34

scopecheck

Go linter checking access to a captured closure var when a closer one is available
Go
2
star
35

twirfony

Symfony support for Twirp
PHP
2
star
36

ergo-http

Http utils extracted from https://github.com/99designs/ergo
PHP
1
star
37

dddk-init

Scaffolding for dddk
TypeScript
1
star
38

sipht

A PHP client for the Sift Science REST API
PHP
1
star