I am quite confused cause when I try to save the resized version of an image it says ‘AttributeError: ‘NoneType’ object has no attribute ‘save”.
I looked over the internet and also to this question: Python Pillow's thumbnail method returning None but i already used the save function so i don’t get why it doesn’t work.
Here’s my code:
from PIL import Image
imgg = Image.open('cropped.tif')
new_image = imgg.thumbnail((400, 400))
new_image.save('thumbnail_400.tif')
I bet it’s something stupid but i can’t see what it is. I appreciate any help.
>Solution :
thumbnail() is an extension method without a return object. The new_image variable will stay None in your case. You need to do this.
from PIL import Image
imgg = Image.open('cropped.tif')
imgg.thumbnail((400, 400))
imgg.save('thumbnail_400.tif')