0

I am inserting GIF image onto my GUI using Tkinter. However I do not know how to auto-scale the size of the image to best fit any resolution. Below are my coding:

from tkinter import * 
import base64
import urllib.request

URL ="file:///C:/Users/Student/Desktop/ezgif.com-resize.gif"
link = urllib.request.urlopen(URL)  
raw_data = link.read()
link.close()
next = base64.encodestring(raw_data)
image = PhotoImage(data=next)
label = Label(image = image)
label.place(x=0,y=0)

Can anyone help me?

destinystazz
  • 13
  • 2
  • 9

1 Answers1

0

Well the link suggests doing something like:

next = base64.encodestring(raw_data)
image = PhotoImage(data=next)
#image = image.zoom(2, 2)      # make it bigger
#image = image.subsample(2, 2) # make it smaller
label = Label(image = image)
label.place(x=0,y=0)

But these two methods are limited to integer scales. If you want to scale more flexibly then you will probably have to use PIL.ImageTk

PS you can use pack() rather than place() to make the image fit nicely.

paddyg
  • 2,153
  • 20
  • 24