Resize and thumbnail

resize and thumbnail.

resize returns a new image. thumbnail mutates and preserves aspect ratio.

Goal

Print sizes after both operations.

from PIL import Image
im = Image.new('RGB', (200, 100), (29, 79, 122))
print(im.resize((50, 25)).size)
from PIL import Image
im = Image.new('RGB', (200, 100), (29, 79, 122))
im.thumbnail((50, 50))
print(im.size)
from PIL import Image
im = Image.new('RGB', (80, 80), (200, 40, 40))
plt.imshow(im.resize((20, 80)))
plt.axis('off')
plt.show()
print('stretched')
from PIL import Image
print(Image.new('RGB', (10, 10)).resize((4, 4), Image.Resampling.NEAREST).size)