On Sat, Apr 25, 2009 at 3:00 PM, Eduardo Ismael <ei...@hotmail.com> wrote:

> I had no success using im.getcolors(). I now there is something you have to
> do to avoid getting None as a result, but I could not understand the
> following from the manual:
>
> "To make sure you get all colors in an image, you can pass in
> size[0]*size[1]"
>
> Can anyone give an example of passing in "size[0]*size[1]"?

"size" refers to the size attribute of the image object.

to prevent unexpected memory/cpu blowup, getcolors() expects you to
specify the maximum number of colors you want.  the default is 256
colors (8 bits); the worst case is obviously the number of pixels in
the image, which you can get by multiplying the width by the height.

    im = .... some image ...
    size = im.size
    colors = im.getcolors(size[0]*size[1])

</F>
_______________________________________________
Image-SIG maillist  -  Image-SIG@python.org
http://mail.python.org/mailman/listinfo/image-sig

Reply via email to