Hello
I'm making an GUI app to open a image and zoom it.
This function is used to open the image & display it:
def file_open(self):
filename =askopenfilename(filetypes=imageTypes)
image1 = ImageTk.PhotoImage(Image.open(filename))
self.canvas.config(height=image1.height(), width=image1.width())
self.canvas.create_image(2, 2, image=image1, anchor=NW)
self.image = image1
self.img_zoom(image1) # passing image1 to img_zoom function
The image is zoomed when I click on zoom in on the menu
viewmenu.add_command(label="Zoom In" ,command=self.img_zoom)
This is the function for zoom:
def img_zoom(self,image1):
width, height = image1.size
image1.resize((width, height), type)
scale = 2
image_resized = image1.resize((int(width*scale), int(height*scale)), Image.ANTIALIAS)
image1 = ImageTk.PhotoImage(image=image_resized)
self.canvas.config(height=image1.height(), width=image1.width())
self.canvas.create_image(2, 2, image=image1, anchor=NW)
self.image = image1
But I am getting an error saying
return self.func(*args)
TypeError: img_zoom() takes exactly 2 arguments (1 given)
So how exactly do I make image1 available to the zoom function
thank you.