- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
$image = imageCreateFromJpeg("test666.jpg");
$width = imageSX($image);
$height = imageSY($image);
$colorsR = array();
$colorsG = array();
$colorsB = array();
for ($i = 0; $i < $width; $i++) {
for ($j = 0; $j < $height; $j++) {
$color = imageColorAt($image, $i, $j);
list($r, $g, $b) = array_values(imageColorsForIndex($image, $color));
if ($r != "255" && $g != "255" && $b != "255") {
array_push($colorsR, $r);
array_push($colorsG, $g);
array_push($colorsB, $b);
}
}
}
$middleR = base_convert(round(array_sum($colorsR) / count($colorsR)), 10, 16);
$middleG = base_convert(round(array_sum($colorsG) / count($colorsG)), 10, 16);
$middleB = base_convert(round(array_sum($colorsB) / count($colorsB)), 10, 16);
echo "<h1>".$middleR.$middleG.$middleB."</h1>"