How to get color map of an image in PHP?
imagecolorat
can only return the color index for a single point,
is there a function to g开发者_如何学编程et all colors in an image?
$im = imagecreatefromgif('php.gif');
$colorCount = imagecolorstotal($im);
$colorSet = array();
for($i=0; $i<$colorCount; ++$i) {
$colorSet[] = imagecolorsforindex($im,$i);
}
It is not very documented, but I think you could use the ImageMagick method described here : http://fr.php.net/manual/en/function.imagick-getimagehistogram.php
精彩评论