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

Craig craigtw.online at gmail.com
Thu Nov 30 22:14:56 EST 2006


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




More information about the Python-list mailing list