PIL自动交换垂直照片的宽度和高度

时间:2016-12-22 10:55:34

标签: python tkinter python-imaging-library

我正在尝试减小垂直照片的宽度和高度,以使图像适合我的屏幕上的tkinter画布。然而,当我用PIL调用width,size = background2.size时,它会自动考虑两个数字中较大的一个宽度,并将图像放在画布上90度角。有没有办法覆盖这个,所以我得到一个较小的垂直图像,以适应我的屏幕?感谢。

background2 = Image.open(background)
width,height = background2.size
if width > 1350 and height >700 and width > height:
    width = 1350
    height = 700
    resized_background = background2.resize((1350,700))
    resized_background.save('C:\\Users\\Kurt\\Desktop\\resized_background.jpg')
elif width > 467 and height > 700 and height > width:
    width = 467
    height = 700
    resized_background = background2.resize((467,700))
    resized_background.save('C:\\Users\\Kurt\\Desktop\\resized_background.jpg')

这为我的background2图像返回(5184,3456),实际上是(3456,5134)。

0 个答案:

没有答案