php提取图片的主要颜色
php提取图片的主要颜色 ```{php}$i = imagecreatefromjpeg(quot;image.jpgquot;);for ($x=0;$xlt;imagesx($i);$x++) { for ($y=0;$ylt;imagesy($i);$y++) { $rgb = imagecolorat($i,$x,$y); $r = ($rgb gt;gt; 16) amp; 0x
$i = imagecreatefromjpeg("image.jpg"); for ($x=0;$x<imagesx($i);$x++) { for ($y=0;$y<imagesy($i);$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);
- 上一篇:php打标签测试
- 下一篇:PHP Coding Tips(PHP的技巧和瑕疵)
精彩图集
精彩文章