468,549 Members | 2,050 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,549 developers. It's quick & easy.

Opening colour BMPs with PIL

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
2 4448
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
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.

Similar topics

3 posts views Thread by Tim Marshall | last post: by
2 posts views Thread by Carl Gilbert | last post: by
11 posts views Thread by Tim Marshall | last post: by
10 posts views Thread by Pulzar | last post: by
20 posts views Thread by Chor Lit | last post: by
17 posts views Thread by mrcw | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by UniDue | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.