Entry
How can I convert a gif image to a bitmap representation of it?
Aug 30th, 2000 21:28
unknown unknown, Greg Landrum
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.
You can find PIL at URL:
http://www.pythonware.com/products/pil/index.htm