views:

80

answers:

2

imagecolorat can only return the color index for a single point,

is there a function to get all colors in an image?

+2  A: 
$im = imagecreatefromgif('php.gif');
$colorCount = imagecolorstotal($im);
$colorSet = array();
for($i=0; $i<$colorCount; ++$i) {
   $colorSet[] = imagecolorsforindex($im,$i);
}
Mark Baker
Each entry in $colorSet in my code is an array like: ( [red] => 226 [green] => 222 [blue] => 252 [alpha] => 0)
Mark Baker
A: 

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

greg0ire