Color count in PIL

Fredrik Lundh fredrik at pythonware.com
Thu Jan 29 19:27:58 EST 2004


"Larry" <wrbt at email.com> wrote:

> I've been walking up, down, and around instances in the object model
> of PIL trying to figure out how to easily calculate how many unique
> colors are used in an image, specifically a bitmap (mode "P"). Am I
> missing something?

colors = len(filter(None, im.histogram()))

</F>







More information about the Python-list mailing list