Opening colour BMPs with PIL

Craig craigtw.online at gmail.com
Mon Dec 4 17:16:25 EST 2006


Hi there,

I'm trying to open colour BMPs using PIL and I'm getting the following
errors.

Opening a 16 colour BMP I get:

>>> im = Image.open("image.bmp")

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 1901, 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 (2)
>>>


Opening a 256 colour BMP I get:

>>> im = Image.open("image.bmp")

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    im = Image.open("image.bmp")
  File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1901, 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)
>>>


Opening a 24 bit colour BMP I get:

>>> im = Image.open("image.bmp")

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    im = Image.open("image.bmp")
  File "C:\Python25\Lib\site-packages\PIL\Image.py", line 1901, 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)
>>>


I am using Windows XP with Python 2.5.  I can open monochrome BMPs fine
but I don't want that.  If you could help that would be greatly
appreciated.  Thanks and good luck.


Craig




More information about the Python-list mailing list