I would like to resize an image using TKinter.
Please note that I will not be using PIL for this.
How can I currently have this image, which works fine.
logo = PhotoImage(file="logo_dribbble-01_1x.PNG")
label = Label(f1,image=logo, borderwidth=0, highlightthickness=0)
label.pack()
I would like to resize this image so that the logo looks smaller.
I tried doing this, which was suggested here
smallLogo = PhotoImage(file="logo_dribbble-01_1x.PNG")
smallLogo = smallLogo.subsample(2, 2)
smallLabel = Label(f1,image=smallLogo, borderwidth=0, highlightthickness=0)
smallLabel.pack()
But this creates an empty label without displaying the image.
I tried to resize the image using Photoshop and use that image and then use that .png image to display the smaller image like so:
logo = PhotoImage(file="logo_dribbble-01_1xsmall.PNG")
smallLabel = Label(f1,image=smallLogo, borderwidth=0, highlightthickness=0)
smallLabel.pack()
But, I get this error when I try to run the code
_tkinter.TclError: encountered an unsupported criticial chunk type "mkBF"
How can I resolve this issue?
3
Answers
I had to keep a reference of the image that was being used by the label like so:
The following code worked for me:
Note I’m on tk-8.6
I think this will solve the problem for you.Your variable for PhotoImage is the same as variable for the Subsample to trim the image for you.
I change the variable for subsample to smallLogo_one the parsed it to the image attribute in the Lable.