问题
So in python i have a Label that I'm using to display images. But the images are rather large and they exceed the size of the label. Is there a way to load the images to fit the label without resizing them?
here is what i do now.
labelWidth = top.winfo_screenwidth()
labelHeight = top.winfo_screenheight()
maxsize = (labelWidth, labelHeight)
im.thumbnail(maxsize, Image.ANTIALIAS)
tkpi = ImageTk.PhotoImage(im)
but this takes way to long.
Thanks in advanced, I'm very new to Python.
回答1:
try:
im = im.resize(maxsize)
instead of:
im.thumbnail(maxsize, Image.ANTIALIAS)
来源:https://stackoverflow.com/questions/26997669/how-to-fit-image-to-label-in-python