Two methods for php to get the average color value of a picture:
$i=imagecreatefromjpeg("jbxue.jpg"); for($x=0;$x>16)&0xff; $g=($rgb>>4)&0xff; $b=$rgb&0xff; $rTotal+=$r; $gToal+=$g; $bToal+=$b; $total++; } } $rAverage=round($rTotal/$total); $gAverage=round($gTotal/$total); $bAverage=round($bTotal/$total);
Example 2, get the value of the color of the picture.
15?dechex($dec):('0'.dechex($dec))); } $im = imagecreatefrompng('http://localhost/image_arc.php'); $rgb = imagecolorat($im,20,20); $r = ($rgb >> 16) & 0xFF; $g = ($rgb >> 8) & 0xFF; $b = $rgb & 0xFF; $RGB = dec2hex($r).dec2hex($g).dec2hex($b); echo "dec:$r-$g-$b
hex:#$RGB"; ?>
The above are the content of the two methods of obtaining the average color value of the image in PHP. For more related content, please pay attention to the PHP Chinese website (m.sbmmt.com)!