• Stars
    star
    1,017
  • Rank 45,237 (Top 0.9 %)
  • Language
    Python
  • License
    Other
  • Created over 9 years ago
  • Updated about 2 years ago

Reviews

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

Repository Details

Grabs the dominant color or a representative color palette from an image. Uses Python and Pillow.

Color Thief

A Python module for grabbing the color palette from an image.

Installation

$ pip install colorthief

Usage

from colorthief import ColorThief

color_thief = ColorThief('/path/to/imagefile')
# get the dominant color
dominant_color = color_thief.get_color(quality=1)
# build a color palette
palette = color_thief.get_palette(color_count=6)

API

class ColorThief(object):
    def __init__(self, file):
        """Create one color thief for one image.

        :param file: A filename (string) or a file object. The file object
                     must implement `read()`, `seek()`, and `tell()` methods,
                     and be opened in binary mode.
        """
        pass

    def get_color(self, quality=10):
        """Get the dominant color.

        :param quality: quality settings, 1 is the highest quality, the bigger
                        the number, the faster a color will be returned but
                        the greater the likelihood that it will not be the
                        visually most dominant color
        :return tuple: (r, g, b)
        """
        pass

    def get_palette(self, color_count=10, quality=10):
        """Build a color palette.  We are using the median cut algorithm to
        cluster similar colors.

        :param color_count: the size of the palette, max number of colors
        :param quality: quality settings, 1 is the highest quality, the bigger
                        the number, the faster the palette generation, but the
                        greater the likelihood that colors will be missed.
        :return list: a list of tuple in the form (r, g, b)
        """
        pass

Thanks

Thanks to Lokesh Dhakar for his original work.

Better

If you feel anything wrong, feedbacks or pull requests are welcome.

More Repositories

1

plan

Crontab jobs management in Python
Python
1,171
star
2

pencil

A web application microframework for Rust
Rust
871
star
3

django-grpc-framework

gRPC for Django.
Python
382
star
4

python-snippets

A basket of python snippets
222
star
5

sender

One easy to use Python SMTP client
Python
197
star
6

easy-python

Libraries you didn't know you would need
192
star
7

rc

Redis cache cluster system in Python
Python
121
star
8

knight

One HTTP development server with reloader for Go
Go
69
star
9

flask-snippets

Flask Snippets
Python
68
star
10

shortly

A URL shortener
Python
50
star
11

flask-profile

Flask Application Profiler
JavaScript
37
star
12

lookup

Look up words via the command line
Python
36
star
13

batpod

A really tiny web framework
Python
23
star
14

python

Python Style Guide
22
star
15

flask-application-wizard

Helper script to create Flask Applications
Python
16
star
16

cli

Rust command line utility
Rust
13
star
17

clock

A minimalist datetime library for Python
Python
10
star
18

pypages

Simple Python Pagination
Python
9
star
19

golang-tour

Sample Go code from the Tour of Go
4
star
20

slim

SimpleHTTPServer serving files relative to the current directory
Go
2
star
21

fengsp.github.io

Shipeng Feng's Writings
HTML
1
star
22

fork

Doing subprocess in Python should be easy
Python
1
star
23

douban-photoalbum-downloader

Download douban photo album
Python
1
star
24

blog

My personal website
HTML
1
star
25

faster-python

Write Faster Python Programs
Python
1
star
26

ninja

The ninja template engine for Go
Go
1
star
27

markdown-online

Put your local markdowns online
JavaScript
1
star
28

pyalgorithms

Algorithms in Python
Python
1
star
29

PyObject

Python 2.5 Source
Python
1
star