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/Image.html#PIL.Image.Image.resize
and
Image.thumbnail
http://pillow.readthedocs.org/en/latest/reference/Image.html#PIL.Image.Image.thumbnail
Both definitions point out to resizing the image, Which one should I be using?
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.