python bmp转换为jpg 并删除原图

匿名 (未验证) 提交于 2019-12-02 22:54:36
# coding:utf-8
import os

from PIL import Image


# bmp 转换为jpg
def bmpToJpg(file_path):
for fileName in os.listdir(file_path):
# print(fileName)
newFileName = fileName[0:fileName.find("_")]+".jpg"
print(newFileName)
im = Image.open(file_path+"\\"+fileName)
im.save(file_path+"\\"+newFileName)


# 删除原来的位图
def deleteImages(file_path, imageFormat):
command = "del "+file_path+"\\*."+imageFormat
os.system(command)


def main():
file_path = "D:\\VideoPhotos"
bmpToJpg(file_path)
deleteImages(file_path, "bmp")


if __name__ == '__main__':
main()
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!