<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_47230"> <div class="blockcode"> <div id="code_Mo9"><ol> <li> <li> <?php <li>/**</li> <li>* php获取图片颜色值</li> <li>* by bbs.it-home.org</li> <li>*/</li> <li>$i=imagecreatefromjpeg("photo3.jpg");//测试图片,自己定义一个,注意路径</li> <li>for ($x=0;$x<imagesx> for ($y=0;$y<imagesy> $rgb = imagecolorat($i,$x,$y);<li> $r=($rgb >>16) & 0xFF;</li> <li> $g=($rgb >> & 0xFF;</li> <li> $b=$rgb & 0xFF;</li> <li> $rTotal += $r;</li> <li> $gTotal += $g;</li> <li> $bTotal += $b;</li> <li> $total++;</li> <li> }</li> <li>}</li> <li>$rAverage = round($rTotal/$total);</li> <li>$gAverage = round($gTotal/$total);</li> <li>$bAverage = round($bTotal/$total);</li> <li>//示例:</li> <li>echo $rAverage;</li> <li>?></li></imagesy></imagesx> </li> </ol></div> <em onclick="copycode($('code_Mo9'));">复制代码</em> </div> </td></tr></table> <div id="comment_47230" class="cm"> </div> <div id="post_rate_div_47230"></div> <br><br>