Closed federico77 closed 8 years ago
Sound like a great feature. Will look into that.
Just saying, there's a similar package here: https://github.com/bfoxwell/ImagePalette
Cool finding! I will probably stick to ImagePalette for a bit even though i'd rather do the whole magic from within the same package i'm manipulating my images with (i assume it would be faster to load an image just once).
Just note that we're using a whitelist of colors which is hardcoded in the ImagePalette class. If you wish more precise results you may want to adjust it (more colors -> slower). :) /off-topic
Option to get all colors used in image will be also good feature :]
Whats the progress on this?
In the past I've used a function on a filter like the following:
/**
* Averages the colors in the image.
* @param \Intervention\Image\Image $image The source image.
* @return int The color average.
*/
private function getColorAverage(Image $image)
{
$image = clone $image;
// Reduce to single color and then sample
$color = $image->limitColors(1)->pickColor(0, 0);
$image->destroy();
return $color;
}
Thanks, ill try that one!
Just sharing, this is a great palette / color extractor library: https://github.com/thephpleague/color-extractor
@olivervogel any update on this?
I think something like this is better off in a separate package. Intervention Image is already bloated.
I know it is a very specific request but I believe it would be a great addition to Intervention: adding a method to find the image dominant color.
There is a great port from the js algorithm here: https://github.com/ksubileau/color-thief-php
I would have forked myself if I was good enough to blend these two tools. :)