Typeerror When Resizing An Image With Pil In Python
Note: This is a self-answered question. I'm trying to resize an image with Python code but I'm getting the following strange error: Traceback (most recent call last): File 'resiz
Solution 1:
After some research I found this question on StackOverflow which is not the same but seems to be related.
@SaranshMohapatra said that he had both PIL and Pillow installed (the same as me) and he solved the problem uninstalling one of them. But I solved the problem in a different way.
I just changed the Image
import.
From: import Image
to: from PIL import Image
and that fixed the problem!
So the final snipped looks like this:
from PIL import Image
logo = Image.open("my_image.png")
logo = logo.resize((100, 100), Image.ANTIALIAS)
logo.save("my_image_resized.png")
Solution 2:
For me works, and seem to be portable, the following code:
try:
from PIL import Image
from PIL import ImageDraw
except ImportError:
import Image
import ImageDraw
Post a Comment for "Typeerror When Resizing An Image With Pil In Python"