文章与视频资源多平台更新
微信公众号|知乎|B站|头条:AI研习图书馆
深度学习、大数据、IT编程知识与资源分享,欢迎关注,共同进步~
1. 介绍
Python代码:批量将BMP图片格式转换为JPG图片格式,即BMP转JPG格式。
2. Python代码
# 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()
您的支持,是我不断创作的最大动力~
欢迎点赞,关注,留言交流~
深度学习,乐此不疲~