Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python PIL image saving

I'm new to PIL library and have some problem.

base = Image.open('sam.bmp')
base.save(open('base.bmp', 'w'), 'BMP')

when I execute that block of code, saved image is distorted in some strange way.

original image: original image

opened and saved image: enter image description here

As you can see, I'm not doing any transformations with the image - only load and save. Do you have any clue, why is it working that way?

like image 341
mnowak Avatar asked Jan 06 '16 19:01

mnowak


2 Answers

As Reti43 said, You just need to use base.save('base.bmp')

like image 95
PsyKzz Avatar answered Oct 19 '22 14:10

PsyKzz


This works :

base = Image.open('sam.bmp')
base.save('base.bmp')
like image 36
Wuilkys Avatar answered Oct 19 '22 12:10

Wuilkys