Open 16-bit/24-bit windows bitmap using PIL

C

Craig

Hi there,

I'm trying to open a 256-colour windows BMP and a 24-bit windows BMP
with PIL usiing the following command:

Image.open("image.bmp")

When I try and open the 24-bit BMP the error I get is:

Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
im = Image.open("lightbulb.bmp")
File "C:\Python25\lib\site-packages\PIL\Image.py", line 1730, in open
return factory(fp, filename)
File "C:\Python25\lib\site-packages\PIL\ImageFile.py", line 82, in
__init__
self._open()
File "C:\Python25\lib\site-packages\PIL\BmpImagePlugin.py", line 164,
in _open
self._bitmap(offset=offset)
File "C:\Python25\lib\site-packages\PIL\BmpImagePlugin.py", line 96,
in _bitmap
raise IOError("Unsupported BMP header type (%d)" % len(s))
IOError: Unsupported BMP header type (108)

When I try and open the 256-colour BMP the error I get is:

Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
im = Image.open("lightbulb2.bmp")
File "C:\Python25\lib\site-packages\PIL\Image.py", line 1730, in open
return factory(fp, filename)
File "C:\Python25\lib\site-packages\PIL\ImageFile.py", line 82, in
__init__
self._open()
File "C:\Python25\lib\site-packages\PIL\BmpImagePlugin.py", line 164,
in _open
self._bitmap(offset=offset)
File "C:\Python25\lib\site-packages\PIL\BmpImagePlugin.py", line 120,
in _bitmap
raise IOError("Unsupported BMP compression (%d)" % compression)
IOError: Unsupported BMP compression (1)

I can open a windows monochrome bitmap fine using PIL but the colour
options are more desirable. I am using Windows 2000 if that is any
help and I am saving the different BMP's using Microsoft Paint. If you
could help that would be great.


Craig
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top