How do I enlarge an image imported onto a Tkinter canvas?

468 views Asked by At

I am working on making a background for my video game but I can't figure out or find out how to make the image larger. My code is:

from tkinter import *
Master = Tk()
Can = Canvas(Master, width=1325, height=400)
img = PhotoImage(file="G.E.N.E.S\Textures\Ppm's\G.E.N.E.S.-1.ppm")
Background = Can.create_image(0,160,anchor=NW,image=img)
Blob = Can.create_oval(650,385,675,360,fil="black")
Can.config(bg="white")
Can.pack()

How can I make the image larger on the Canvas? I'd really appreciate anyone's help. Note: I cant install any modules because I'm working at school. P.S. I'm sorry but I can't figure out how to put a screen shot in.

1

There are 1 answers

2
Taku On

You can use the .zoom method.

img = PhotoImage(file="G.E.N.E.S\Textures\Ppm's\G.E.N.E.S.-1.ppm")
img.zoom(2,2) # x, y 

This will make the image larger by 2x both height and width. If x or y is not specified, x or y will stay the same.