一、# python图片格式jpg转换为png(批量处理,尺寸不变)
author: zhou jinxing
import os
import PIL.Image as Image
def changeJpgToPng(srcPath, dstPath):
# 修改图像大小
image = Image.open(srcPath)
# 将jpg转换为png
png_name = str(dstPath)[0:-len('.jpg')] + '.png'
# image.save(png_name)
# print(png_name)
# image = image.convert('RGBA')
image = image.convert('RGB')
image.save(png_name)
pass
if __name__ == '__main__':
listPath = 'D:/BYLW666/deeplabv3-plus-pytorch-main/VOCdevkit/VOC2007/jpg/'#jpg图片
srcPath = 'D:/BYLW666/deeplabv3-plus-pytorch-main/VOCdevkit/VOC2007/src/'#jpg图片
dstPath = 'D:/BYLW666/deeplabv3-plus-pytorch-main/VOCdevkit/VOC2007/png/'#png图片
print("开始转换...")
filename_list = os.listdir(listPath)
for d in filename_list:
if d.count('.jpg') > 0: