Intervention / image

PHP Image Processing
https://image.intervention.io
MIT License
13.93k stars 1.5k forks source link

Get dominant color #80

Closed federico77 closed 8 years ago

federico77 commented 10 years ago

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. :)

olivervogel commented 10 years ago

Sound like a great feature. Will look into that.

gandalfx commented 10 years ago

Just saying, there's a similar package here: https://github.com/bfoxwell/ImagePalette

federico77 commented 10 years ago

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).

gandalfx commented 10 years ago

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

ghost commented 10 years ago

Option to get all colors used in image will be also good feature :]

JackPoint commented 9 years ago

Whats the progress on this?

willrowe commented 9 years ago

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;
}
JackPoint commented 9 years ago

Thanks, ill try that one!

andrefelipe commented 8 years ago

Just sharing, this is a great palette / color extractor library: https://github.com/thephpleague/color-extractor

cmnstmntmn commented 8 years ago

@olivervogel any update on this?

olivervogel commented 8 years ago

I think something like this is better off in a separate package. Intervention Image is already bloated.