简体   繁体   中英

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: 原始图像

opened and saved image: 在此输入图像描述

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?

正如Reti43所说,你只需要使用base.save('base.bmp')

This works :

base = Image.open('sam.bmp')
base.save('base.bmp')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM