The problem: I have a bunch of images and need to filter those that are too dark, e.g. have too much black in them.
I have looked into PHP's Imagick and GD docs but could not find a function to give me an image's saturation or hue. I'd need some efficient method to find out if an image is more than 70% black, from JPeg-Images.
Perhaps a bit late to the party, but this came up in Google's results, so I thought I'd provide my answer.
Likely what you're looking to do is change the brightness. Below is the script I use. The $target_mean
can be fiddled with if the script is making the image too bright or not bright enough.
```php
$target_mean = 46000;
$Img = new Imagick('/path/to/file.jpg');
$mean = $Img->getImageChannelMean(imagick::CHANNEL_ALL)['mean'];
if($target_mean > $mean * 1.05){//don't change if brightness is within 5%
$perc_diff = ($target_mean / $mean) * 100;
$Img->modulateImage($perc_diff,100,100);
$Img->writeImage('/path/to/file.jpg');
}