如下所示:
# 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()
以上这篇python bmp转换为jpg 并删除原图的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
继续阅读与本文标签相同的文章
-
《Android高性能编程》| 每日读本书
2026-05-18栏目: 教程
-
上海市增值税发票管理系统25日停机前需完成以下事项
2026-05-18栏目: 教程
-
设计建设网站前,网站安全整体解决方案全解析!
2026-05-18栏目: 教程
-
三年从业经验且非科班出身的中年Java程序员如何保持岗位竞争力
2026-05-18栏目: 教程
-
谷歌放弃Daydream移动VR平台 因未达到使用预期
2026-05-18栏目: 教程
