python实现.jpeg转.jpg

from PIL import Image
import os
 
def jpeg2jpg(path_in, path_out):
    img = Image.open(path_in)
    img.save(path_out, "JPEG", quality=80, optimize=True, progressive=True)
 
 
test_dir = "./1/"#.jpeg图片所在文件夹
out_dir = "./2/"#转化成.jpg图片所在文件夹
jpg = ".jpg"
jpeg = ".jpeg"

pics = os.listdir(test_dir)

for img in pics:
    im=os.path.splitext(img)[0]
    source = test_dir+im+jpeg
    target = out_dir+im+jpg
    jpeg2jpg(source, target)

你可能感兴趣的:(Python,python)