python代码:jpeg图像转jpg图像

from PIL import Image

def jpeg2jpg(path_in, path_out):
    img = Image.open(path_in)
    img.save(path_out, "JPEG", quality=80, optimize=True, progressive=True)


path1 = "/export/liuzhe/program2/PyTorch-GAN-master/data/FLIR/train/a/"
path2 = "/export/liuzhe/program2/PyTorch-GAN-master/data/FLIR/train/a1/"
jpg = ".jpg"
jpeg = ".jpeg"
for i in range(1, 15000):
    i = "%05d" % i
    source = path1+"FLIR_"+str(i)+jpeg
    target = path2+"FLIR_"+str(i)+jpg
    jpeg2jpg(source, target)

 

你可能感兴趣的:(code)