I created a function to count the colors in a .gif file automatically. Works perfect on Win2k Servers
<?PHP
function bildinfo($bild)
{
$fp = fopen($bild, "rb"); $f = fread($fp, filesize($bild));
$c = bin2hex($f); $c = ereg_replace("5c30", "0000", $c); $b = $c;
$pos = strpos($c, "fe0102"); if ($pos > 0)
{
$c = substr($c, 26);
$c = substr($c, 0, strpos($c, "fe0102")); }
else
{
$c = substr($c, 26);
$c = substr($c, 0, strpos($c, "21f904")); }
echo "<table border='0'>";
$i = 0;
$y = 0;
$str = "";
$pix = chunk_split($c, 6, ";"); $pix = explode(";",$pix);
sort($pix);
foreach($pix as $col)
{
if ($col && !ereg($col.";", $str) && strlen($col) == 6) {
$str .= $col.";";
$i++; $y++; if ($i == 1) { echo ""; }
echo "<td width='6' height='8' bgcolor='#$col' style='border:1px solid #000000;font-size:1px;' title='2003 by www.BLACKEYE.org'>";
echo " ";
echo "</td>";
if ($i == 10)
{
echo ""; $i = 0;
}
}
}
echo "</table>";
echo $y." visible colors";
}
$bild = ""; bildinfo($bild);
?>
Only copy & paste this text into your .php file, where you want to show the image.