Python: Cannot open converted bitmap image file, converted using PIL

3k views Asked by At

How do I go about converting a JPG file to BMP using PIL? Tried to use Image.open('ifile.jpg').save('ofile.bmp', 'BMP') but I get a 'bogus header data' when attempting to open the file.

Tried the copy / paste method as described in Convert RGBA PNG to RGB with PIL but it does not work too.

1

There are 1 answers

1
urcm On

there is no problem in the code.(i have tried the following code and worked well.) it converts your file to desired format.

import Image
im = Image.open("test.bmp")
im.save("test.jpg", "JPEG")

i think the problem is about Ubuntu. I also met a few times and I think it is a bug. try to open with gimp...