GithubHelp home page GithubHelp logo

fengsp / color-thief-py Goto Github PK

View Code? Open in Web Editor NEW
996.0 996.0 122.0 14 KB

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

Home Page: http://lokeshdhakar.com/projects/color-thief/

License: Other

Makefile 1.84% Python 98.16%

color-thief-py's People

Contributors

crazyzubr avatar fengsp 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

color-thief-py's Issues

get_palette() returns 1+color_count colors

dominant_color = ColorThief(image).get_palette(color_count=3, quality=10)
returns
[(47, 36, 65), (171, 176, 180), (139, 153, 171), (122, 134, 165)]
(with this particular image).

The RGB values get_palette is > 255

For a certain image the RBG value was (256, 252, 212) This value for R should not exists as RGB values are 32 bit values [0-255]. Cant share the image for privacy reasons.

how do i get color count percentage?

hi, i am calling get_palette() function to get dominant colors and i need to have percentage of each color i mean when i get 6 color from this function i need to know how many pixels of that color in the image. how can i get that info?

Creating a fork

I don't want to do this myself as I'm not too familiar with PyPi or exactly how this code works but someone with more experience should really make a fork where pull requests can actually get merged and issues fixed.

Does this still work

Screen Shot 2022-07-15 at 7 19 00 PM

I've tried and pycharm will not recognize or install via 'pip install colorthief` and i've already tried via conda but it will not install `color-thief-py`, `color-thief`, or `colorthief`

The repo files are looking like they are six to seven years old June 12 2015, and the last Pypi update was 2017 https://pypi.org/project/colorthief/

get_palette crashing on one image

Hi,

I've run get_palette on thousands of images with no issues. I have one jpg that it just crashes on. The message returned is "killed".

image

ImportError: cannot import name ColorThief

Though my install says

Requirement already satisfied: colorthief in /home/quinten/anaconda2/lib/python2.7/site-packages
Requirement already satisfied: Pillow in /home/quinten/anaconda2/lib/python2.7/site-packages (from colorthief)
Requirement already satisfied: olefile in /home/quinten/anaconda2/lib/python2.7/site-packages (from Pillow->colorthief)

About complete white image having values (254,254,254)

The code will not be able to detect complete dominant white images with values like (254,254,254).

Please modify the code of get_palette() to:

r, g, b, a = pixels[i]
            # If pixel is mostly opaque and not white
            if a >= 125:
                if not (r > 255 and g > 255 and b > 255):
                    valid_pixels.append((r, g, b))

Setting the threshold of 250 is causing the problem

Pass in image to __init__ instead of filename

Sometimes you already have the image as a PIL Image object and re-reading as another Image is a wasted of memory. Currently, I'm re-implementing ColorThief like this:

# Overrides init of ColorThief to pass in the buffer from memory
class ColorThiefFromImage(ColorThief):
    def __init__(self, image):
        self.image = image

Inaccurate results

The results provided by the python wrapper seem to vary a lot as compared to the results provided by https://lokeshdhakar.com/projects/color-thief/#examples

For example, here's the result of the website as compared to the result of the py wrapper.

Screenshot 2020-04-28 at 7 00 07 PM

RGB: (219,210,202)

Whereas the python wrapper gives the RGB output as (61, 54, 40)

I tried alternating the quality from 10 to 1 but I can't get a result close to the original result.

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.