Opening colour BMPs with PIL

C

Craig

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:

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:

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:

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
 
F

Fredrik Lundh

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

what program did you use to produce those BMP files? can you prepare
reasonably small samples using the same program and post them somewhere?

</F>
 
C

Craig

Fredrik said:
what program did you use to produce those BMP files? can you prepare
reasonably small samples using the same program and post them somewhere?

</F>

Thanks for the reply. I'm using Microsoft Paint to create the files so
that's most likely the problem (surprise, surprise). I found that by
using GIMP to create them has no problems with opening BMP images.
I'll just keep using GIMP instead.
 

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,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top