By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,274 Members | 2,229 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,274 IT Pros & Developers. It's quick & easy.

Opening colour BMPs with PIL

P: n/a
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

Dec 4 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Craig wrote:
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>

Dec 5 '06 #2

P: n/a
Fredrik Lundh wrote:
Craig wrote:
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>
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.

Dec 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.