gif to bitmap in python

Greg Landrum glandrum at my-deja.com
Tue Aug 29 11:58:39 EDT 2000


In article <8oghku$a9t$1 at nnrp1.deja.com>,
  tiddlerdeja at my-deja.com wrote:
> Can anyone tell me how, or give an example of howto convert a gif
image
> to a bitmap representation of it?
>

I'm not completely sure what you mean by "bitmap representation", but
PIL probably does what you want.  :-)

To convert to a BMP (windows bitmap), you would do:
>>> from Pil import Image
>>> img = Image.open('foo.gif')
>>> img.save('foo.bmp')

If you would rather get a Numeric array with the values from the image:
>>> from Pil import Image
>>> from Numeric import *
>>> img = Image.open('foo.gif')
>>> arr = resize(fromstring(img.tostring(),Int8),img.size)

I hope this helps.
-greg




Sent via Deja.com http://www.deja.com/
Before you buy.



More information about the Python-list mailing list