fengsp / color-thief-py

Grabs the dominant color or a representative color palette from an image. Uses Python and Pillow.
http://lokeshdhakar.com/projects/color-thief/
Other
1.04k stars 125 forks source link

Pass in image to __init__ instead of filename #13

Open davidhariri opened 5 years ago

davidhariri commented 5 years ago

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
gsornsen commented 5 years ago

I submitted a pull request with my changes to support both. I needed it as well: https://github.com/fengsp/color-thief-py/pull/16