This code shows the palettes for all .gif files in the current working directory. (Output is HTML.)
<?php
print '<pre>';
foreach(glob('*.gif') as $src_fn)
{
$im2 = ImageCreateFromGif($src_fn);
echo '<a href="',htmlspecialchars($src_fn),'">';
print sprintf('%-30s', $src_fn);
echo '</a>';
$cc = ImageColorsTotal($im2);
for($n=0; $n<$cc; ++$n)
{
$c = ImageColorsForIndex($im2, $n);
print
sprintf('<span style="background:#%02X%02X%02X"> </span>',
$c['red'], $c['green'], $c['blue']);
}
ImageDestroy($im2);
print "\n";
}
print '</pre>';
?>