I have made this code that displays an image after resizing it
import tkinter as tk
from PIL import Image, ImageTk
def resize(picname, ratio):
image = Image.open(picname)
image = image.resize((int(image.size[0]*ratio), int(image.size[1]*ratio)), Image.ANTIALIAS)
image = ImageTk.PhotoImage(image)
return image
swidth, sheight = 1366, 900
root = tk.Tk()
root.geometry(str(swidth)+'x'+str(sheight)+'+0+0')
cv = tk.Canvas(root, width = swidth, height = sheight)
cv.pack()
tempimage = resize('man.gif', 1.5)
imaj = cv.create_image(0, 0, image = tempimage, tag ='man')
while True:
cv.coords('man', 500, 500)
print(cv.coords(imaj))
cv.update()
tk.mainloop()
But this code does not display the picture Even when I check the output I get [500.0, 500.0]
This code works without the 'resize', any idea why?
EDIT:
I got the resizing code from this link, from the answer by Joshkunz. This code works when I have one image object. But not when I have multiple, for some reason. Could someone please explain!