Python:JPG->JPEG

Due to the use of images on a web page to load progressive, so it is necessary to convert other image formats to JPEG format

Consider using python to achieve batch conversion

You need to install pillow:

pip  install pillow

 

I'm here to JPG format into JPEG:

code:

from PIL import Image

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


path = "D:"
jpg = ".jpg"
jpeg = ".jpeg"
for i in range(1, 15):
    source = path+str(i)+jpg
    target = path+str(i)+jpeg
    jpg2jpeg(source, target)

Guess you like

Origin www.cnblogs.com/XT-xutao/p/12081581.html