How do I resize an image using PIL and maintain its aspect ratio?

后端 未结 20 1860
-上瘾入骨i
-上瘾入骨i 2020-11-22 02:30

Is there an obvious way to do this that I\'m missing? I\'m just trying to make thumbnails.

20条回答
  •  醉话见心
    2020-11-22 02:43

    You can resize image by below code:

    From PIL import Image
    img=Image.open('Filename.jpg') # paste image in python folder
    print(img.size())
    new_img=img.resize((400,400))
    new_img.save('new_filename.jpg')
    

提交回复
热议问题