[Image-SIG] using getcolors( ) properly
eismb at hotmail.com
Tue Apr 28 05:49:12 CEST 2009
Thanks, Fredrik - it finally works.
> From: fredrik at pythonware.com
> Date: Mon, 27 Apr 2009 13:44:31 +0200
> Subject: Re: [Image-SIG] using getcolors( ) properly
> To: eismb at hotmail.com
> CC: image-sig at python.org
> On Sat, Apr 25, 2009 at 3:00 PM, Eduardo Ismael <eismb at 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*size"
> > Can anyone give an example of passing in "size*size"?
> "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*size)
Messenger 2009: Instale já!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Image-SIG