[Image-SIG] using getcolors( ) properly

Eduardo Ismael 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[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>

_________________________________________________________________
Messenger 2009: Instale já!
http://download.live.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/image-sig/attachments/20090428/94955ab8/attachment-0001.htm>


More information about the Image-SIG mailing list