473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Convert PNG files to BMP files using PIL

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:
>>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
>>>
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

Dec 4 '06 #1
2 8680
Craig wrote:
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:
>>>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.
>>im.convert("1").tobitmap()
im.convert("1", dither=Image.NONE).tobitmap()
im.point(table, "1").tobitmap()
etc.

</F>

Dec 4 '06 #2
Craig wrote:
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/
Dec 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Swarup | last post by:
I am reading a file (txt, xml, gif, ico, bmp etc) byte by byte and filling it into a byte arry. Now i have to convert it into a string to store it in the database. I use...
5
by: melickas | last post by:
We designed a custom application using Office Developer Tools '97 which included a Run-time version of Access--- so it would not matter if our customer even had any version of Access on their...
5
by: bbb | last post by:
Hi, I need to convert XML files from Japanese encoding to UTF-8. I was using the following code: using ( FileStream fs = File.OpenRead(fromFile) ) { int fileSize = (int)fs.Length; int buffer...
3
by: GM | last post by:
Dear all, Could you all give me some guide on how to convert my big5 string to unicode using python? I already knew that I might use cjkcodecs or python 2.4 but I still don't have idea on what...
4
by: csgraham74 | last post by:
Hi, Ive posted on this previously but had no response. Basically i need to build some html using a rich text editor. Then i want to actually create an html document from this and save it to my...
6
by: leonel.gayard | last post by:
Hi, Does anyone know a good python library to convert a RTF file into PDF ? This should be done automaticaly: I have a web page that takes some values and inserts them into a RTF template,...
2
by: edw | last post by:
I want to convert rfc822 (.eml) files to MAPI (.msg) files. I do not need to log in to Outlook to retrieve the messages, since the messages have all been downloaded from the exchange server and...
3
by: Sun | last post by:
Hi everyone . I have two files named a.txt and b.txt. I open a.txt with ultraeditor.exe. here is the first row of the file: neu für then I switch to the HEX mode: 00000000h: FF FE 6E 00 65...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.