If there are less than 256, choosing image>mode>indexed color… will give you a count. Beyond that, the most possible would be 16,777,216. How to count them is beyond me.
Photoshop doesn’t offer the capability to count the colors used in an image. The easiest, and cheapest, way to do that is to download and install the freeware application IrfanView from <http://www.irfanview.com>. Open the image in IrfanView and go to Image > Count Colors.
Just out of curiosity, why do you want/need to know the number of colors in an image? I only ask because – other than in the case of an indexed-color image – I can’t come up with a practical reason for needing to know, or in what way having this information would solve a problem. Can you fill me in?
for me, it’s just curiosity. When I began digital imaging I could not imagine why the 256 colours of GIF are not enough (with a watercolor palette of only 12 colours you can do a lot!).
I then quickly found out that a picture consists of 10 or 100’s of thousands of different colours, even if I take a picture of only green grass.
But you are right, I do not use this information in my daily workflow.