Connecting Tech Pros Worldwide Forums | Help | Site Map

Convert PNG files to BMP files using PIL

Craig
Guest
 
Posts: n/a
#1: Dec 4 '06
Hi there,

I'm trying to convert some PNG files to bitmap files which can then be
converted to X11 bitmaps using the im.tobitmap() function. But the
error I get when using the im.tobitmap() function on the PNG files I
get the following error:
Quote:
Quote:
Quote:
>>im.tobitmap()
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
im.tobitmap()
File "C:\Python25\Lib\site-packages\PIL\Image.py", line 545, in
tobitmap
raise ValueError("not a bitmap")
ValueError: not a bitmap
Quote:
Quote:
Quote:
>>>
Can this be done using PIL or is there another library that can be used
to fulfil the task. If you could let me know that would be great.
Thanks and good luck.


Craig


Fredrik Lundh
Guest
 
Posts: n/a
#2: Dec 4 '06

re: Convert PNG files to BMP files using PIL


Craig wrote:
Quote:
I'm trying to convert some PNG files to bitmap files which can then be
converted to X11 bitmaps using the im.tobitmap() function. But the
error I get when using the im.tobitmap() function on the PNG files I
get the following error:
>
Quote:
Quote:
>>>im.tobitmap()
tobitmap() only works for mode "1" images. if you have something else,
you need to map it to black & white first, e.g.
Quote:
Quote:
Quote:
>>im.convert("1").tobitmap()
>>im.convert("1", dither=Image.NONE).tobitmap()
>>im.point(table, "1").tobitmap()
etc.

</F>

Soni Bergraj
Guest
 
Posts: n/a
#3: Dec 4 '06

re: Convert PNG files to BMP files using PIL


Craig wrote:
Quote:
Can this be done using PIL or is there another library that can be used
to fulfil the task. If you could let me know that would be great.
Thanks and good luck.
Not sure if this solves your particular problem, but have you considered
ImageMagick? There are python bindings at
http://www.imagemagick.org/script/api.phpm

Cheers,
--
Soni Bergraj
http://www.YouJoy.org/
Closed Thread