\n"; $colorstotal = imagecolorstotal($img); $arrcolors[0] = 0; // loop through all pixels in image, looking at the color for ( $x = 1; $x <= $countx; $x += 1) { echo "."; for ( $y = 1; $y <= $county; $y += 1) { $pixelrgb = imagecolorat($img, $x, $y); if (is_int($pixelrgb)) { if (array_key_exists($pixelrgb, $arrcolors)) { $arrcolors[$pixelrgb] += 1; } else { $arrcolors[$pixelrgb] = 1; } } } } echo "\n"; // loop though array of colors, outputting count of pixels of each color reset($arrcolors); foreach ($arrcolors as $key=>$val) { // to break out the byte values if needed: $cols = imagecolorsforindex($img, $key); $r = $cols['red']; $g = $cols['green']; $b = $cols['blue']; $a = $cols['alpha']; echo $key.",".$val.",".$r.",".$g.",".$b.",".$a."
\n"; } ?>