批量bmp修改格式为png
import os
os.system("pip3 install pillow")
from PIL import Image
def con(input, output):
bmp_image = Image.open(input)
bmp_image.save(output, format='png', quality=95)
def _dir(_d):
for i in os.listdir(_d):
t = os.path.join(_d, i)
if os.path.isfile(t) and t.split(".")[-1] == 'bmp':
out = t.replace(".bmp", '.png')
con(t, out)
elif os.path.isdir(t):
_dir(t)
# 文件夹
_d = r""
# 处理
_dir(_d)
本文来自博客园,作者:love_water,转载请注明原文链接:https://www.cnblogs.com/ldsice/p/17495982.html

浙公网安备 33010602011771号