py_bmptojpg

#***************************************************************
import os
from PIL import Image

file_path = os.getcwd()
trans_count = 0

def b2j(file_path):

for fileName in os.listdir(file_path):
if os.path.splitext(fileName)[1] == '.bmp':#指定bmp文件后缀
newFileName = fileName[0:fileName.find(".")]+".jpg"
im = Image.open(file_path+"/"+fileName)
im.save(file_path+"/"+newFileName)
global trans_count
trans_count += 1
print(f"transform_count:{trans_count}")

b2j(file_path)

print('bmp to jpg has been completed!')

posted @ 2024-08-12 16:23  abs8023  阅读(13)  评论(0)    收藏  举报