I have a jpg image.
I need to know \"overall average\" the color of the image. At first glance there can use the histogram of the image (channel RGB).
At wor
Combining JKirchartz and Alexander Hugestrand answer:
function getAverage($sourceURL){
$image = imagecreatefromjpeg($sourceURL);
$scaled = imagescale($image, 1, 1, IMG_BICUBIC);
$index = imagecolorat($scaled, 0, 0);
$rgb = imagecolorsforindex($scaled, $index);
$red = round(round(($rgb['red'] / 0x33)) * 0x33);
$green = round(round(($rgb['green'] / 0x33)) * 0x33);
$blue = round(round(($rgb['blue'] / 0x33)) * 0x33);
return sprintf('#%02X%02X%02X', $red, $green, $blue);
}
Tried and tested, returns hex string.