等比例缩小放大图片

    技术2024-11-30  13

    设置读入、输出文件以及缩小/放大比例

    imgfile = 'E:/PycharmProjects/PracticalTableau/img/191119-8.png' outfile = 'E:/PycharmProjects/PracticalTableau/img/191119-8_resize.png' resize = 0.8

    缩小/放大图片文件并输出

    from PIL import Image img = Image.open(imgfile) w,h = img.size w,h = round(w * resize),round(h * resize) img = img.resize((w,h), Image.ANTIALIAS) # img = img.resize((round(1366*resize),round(768*resize)), Image.ANTIALIAS) img.save(outfile, optimize=True, quality=85)
    Processed: 0.013, SQL: 9