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

后端 未结 20 2116
-上瘾入骨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:58

    If you don't want / don't have a need to open image with Pillow, use this:

    from PIL import Image
    
    new_img_arr = numpy.array(Image.fromarray(img_arr).resize((new_width, new_height), Image.ANTIALIAS))
    

提交回复
热议问题