> Do you need to know how many different colours are used in an image? > > Here's how do it for nearly any image type using the command line: > > pngtopnm foo.png | pnmtoplainpnm | tail +4 | tr -s " " | tr " " "\n" | > sort -n | uniq | wc -l > > If your image is something other than png, then replace the first > command with jpegtopnm, giftopnm, bmptopnm, or whatever.
Here's an alternative and somewhat easier method, which also works with 16bit/colour images if ImageMagick has been suitably compiled, and works with any image type which IM can recognise. identify -verbose ... | grep Colors: If you're only interested in how many colours can potentially have been used by this image, leave out the -verbose (it's magnitudes faster then). Volker -- Volker Kuhlmann is possibly list0570 with the domain in header http://volker.dnsalias.net/ Please do not CC list postings to me.
