📜  将文件转换为 JPEG - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:33.545000             🧑  作者: Mango

代码示例2
import os, sys
from PIL import Image

for infile in sys.argv[1:]:
    f, e = os.path.splitext(infile)
    outfile = f + ".jpg"
    if infile != outfile:
        try:
            with Image.open(infile) as im:
                im.save(outfile)
        except OSError:
            print("cannot convert", infile)