【问题标题】:Tkinter make an image smaller without losing detailTkinter 使图像更小而不会丢失细节
【发布时间】:2018-05-09 22:19:56
【问题描述】:

目前我正在使用“子样本”,以便图像不会填满屏幕,但我注意到这样做会降低质量。

PhotoImage(file=image).subsample(5)

(左 = tkinter 上的图像,右 = 油漆上的图像)

如何在不损失质量的情况下缩小图像?

【问题讨论】:

    标签: python python-3.x tkinter


    【解决方案1】:

    我建议使用 Pillow(以前称为 PIL,现已弃用)。

    使用 Pillow,您可以使用 thumbnail() 函数缩小图像,或者如果您希望增加图像的大小,resize() 函数也可以使用。

    from PIL import Image
    size = 128, 128    
    im = Image.open(infile)
    im.thumbnail(size)
    im.save(file + ".thumbnail", "JPEG")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-20
      • 2010-11-16
      • 2014-09-20
      • 2010-09-28
      • 1970-01-01
      • 1970-01-01
      • 2022-01-19
      • 1970-01-01
      相关资源
      最近更新 更多