Number of colors in an image
Tim Hoffman
timh at zute.net
Sat Nov 27 02:10:03 EST 2004
Have a look at the histogram function of PIL
Tim
Laszlo Zsolt Nagy wrote:
> Hello David,
>
> Friday, November 26, 2004, 11:18:04 PM, you wrote:
>
>
>
>>For example, for an RGB image:
>
>
>> import sys
>> from PIL import Image
>> from itertools import izip, repeat
>
>
>> if __name__ == "__main__":
>
>
>> im = Image.open(sys.argv[1])
>> r = im.getdata(0)
>> g = im.getdata(1)
>> b = im.getdata(2)
>> print 'Number of colors =', len(colors)
>
>
> Thank you, this was very helpful. I'll try to use this one instead of
> ImageMagick. (The identify program does not work in some cases...)
>
More information about the Python-list
mailing list