开发者

How to get color map of an image in PHP?

开发者 https://www.devze.com 2023-01-03 15:52 出处:网络
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\');

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

0

精彩评论

暂无评论...
验证码 换一张
取 消