What is the difference between Image.resize and Image.thumbnail in Pillow-Python

前端 未结 1 1108

I want to resize an image in pillow-python, however I have 2 functions of choice to use:

Image.resize http://pillow.readthedocs.org/en/latest/reference/

1条回答
  •  独厮守ぢ
    2020-12-05 17:50

    Image.resize resizes to the dimensions you specify:

    Image.resize([256,512],PIL.Image.ANTIALIAS) # resizes to 256x512 exactly
    

    Image.thumbnail resizes to the largest size that (a) preserves the aspect ratio, (b) does not exceed the original image, and (c) does not exceed the size specified in the arguments of thumbnail.

    Image.thumbnail([256, 512],PIL.Image.ANTIALIAS) # resizes 512x512 to 256x256
    

    Furthermore, calling thumbnail resizes it in place, whereas resize returns the resized image.

    0 讨论(0)
提交回复
热议问题