Получаем основной цвет изображения

August 19, 2014

    $i = imagecreatefromjpeg(«image.jpg»);

for ($x=0;$x for ($y=0;$y $rgb = imagecolorat($i,$x,$y);
$r = ($rgb >> 16) & 0xFF;
$g = ($rgb >> & 0xFF;
$b = $rgb & 0xFF;

$rTotal += $r;
$gTotal += $g;
$bTotal += $b;
$total++;
}
}

$rAverage = round($rTotal/$total);
$gAverage = round($gTotal/$total);
$bAverage = round($bTotal/$total);

Комментарии

comments powered by Disqus