Home > Backend Development > PHP Tutorial > How to determine the color type of an image in php? Example tutorial

How to determine the color type of an image in php? Example tutorial

WBOY
Release: 2016-07-25 08:52:55
Original
1110 people have browsed it
  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);
复制代码


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template