How To Get Rid Of The Resize Attribute Error?
I'd like to know if I did something wrong in my code or if I have to update something cause every single time I try to resize an image I have this: Attribute Error 'PhotoImage' ob
Solution 1:
The error means what it says, PhotoImage
object does not have resize
attribute, then what has? It is the Image
object that has resize
. You can remove your first PhotoImage
(because it uses resize
), as its no use:
image1 = Image.open("enseigne.JPEG")
imageresize = image1.thumbnail((500,500), Image.ANTIALIAS)
imageresize = ImageTk.PhotoImage(imageresize)
limage = tk.Label(app, image=imageresize)
If you want shorter code:
image1 = ImageTk.PhotoImage(Image.open("enseigne.JPEG").thumbnail((500,500), Image.ANTIALIAS))
limage = tk.Label(app, image=image1)
Obvious question: You are not calling resize
but why are you getting such error? It is because thumbnail
uses resize
implicitly(based on conditions).
Post a Comment for "How To Get Rid Of The Resize Attribute Error?"