thephpleague / color-extractor

Extract colors from an image like a human would do.
thephpleague.com
MIT License
1.3k stars 159 forks source link

Better Palette generation #51

Closed joeworkman closed 2 years ago

joeworkman commented 6 years ago

I love the interface of this package. However, the palette that it generates contains the color value of every pixel it seems, even if the colors are nearly indistinguishable. I would love to be able to find the 5 most used colors that are actually in different color spectrums instead of 5 colors that are practically the same color.

I have been using this package to find a good color palette https://github.com/ksubileau/color-thief-php but its interface is not quite as nice as this one.

Octolus commented 6 years ago

Agreed. It returned literally everything, i only want to know the top 5 most used ones :(

demianh commented 2 years ago

I guess what you are looking for ist the ColorExtractor (as described in the Readme)?

$palette = Palette::fromFilename('./some/image.png');
$extractor = new ColorExtractor($palette);
// extract() returns the most “representative” colors
$colors = $extractor->extract(5);
MatTheCat commented 2 years ago

I guess that was it ¯_(ツ)_/¯