Image resize under PhotoImage

Because both zoom() and subsample() want integer as parameters, I used both.

I had to resize 320×320 image to 250×250, I ended up with

imgpath="/path/to/img.png"
img = PhotoImage(file=imgpath)
img = img.zoom(25) #with 250, I ended up running out of memory
img = img.subsample(32) #mechanically, here it is adjusted to 32 instead of 320
panel = Label(root, image = img)

Leave a Comment