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

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

    If you are trying to maintain the same aspect ratio, then wouldn't you resize by some percentage of the original size?

    For example, half the original size

    half = 0.5
    out = im.resize( [int(half * s) for s in im.size] )
    

提交回复
热议问题