当前位置:Gxlcms > PHP教程 > php如何判断图片颜色类型?实例教程

php如何判断图片颜色类型?实例教程

时间:2021-07-01 10:21:17 帮助过:14人阅读

  1. $i = imagecreatefromjpeg("image.jpg");
  2. for ($x=0;$xfor ($y=0;$y$rgb = imagecolorat($i,$x,$y);
  3. $r = ($rgb >> 16) & 0xFF;
  4. $g = ($rgb >> & 0xFF;
  5. $b = $rgb & 0xFF;
  6. $rTotal += $r;
  7. $gTotal += $g;
  8. $bTotal += $b;
  9. $total++;
  10. }
  11. } // bbs.it-home.org
  12. $rAverage = round($rTotal/$total);
  13. $gAverage = round($gTotal/$total);
  14. $bAverage = round($bTotal/$total);

人气教程排行