PIL:如何放大图像并将其放入标签中?
PIL: How do I enlarge an image and fit it into in a label?
我无法将照片放大并放入标签中。
def displayimage(self, _event=None):
if self.videopath != "" and self.txtsequenceframe.get() != "":
# Placing the lable in a different location at runtime
self.photodisplay.place(width=700, height=500, x=0, y=0)
self.currentphoto = Image.open(self.framepaths[int(self.txtsequenceframe.get())])
self.currentphoto.resize((700, 500), Image.ANTIALIAS)
self.currentphotoready = ImageTk.PhotoImage(self.currentphoto)
self.photodisplay.config(image=self.currentphotoready)
我搜索过这个主题,但他们创建了一个新标签并将图像放入其中。实际上我想多次更改该图像。谁能帮我解决这个错误?
def displayimage(self, _event=None):
if self.videopath != "" and self.txtsequenceframe.get() != "":
# Placing the lable in a different location at runtime
self.photodisplay.place(width=700, height=500, x=0, y=0)
self.currentphoto = Image.open(self.framepaths[int(self.txtsequenceframe.get())])
self.currentphoto = self.currentphoto.resize((700, 500), Image.ANTIALIAS)
self.currentphotoready = ImageTk.PhotoImage(self.currentphoto)
self.photodisplay.config(image=self.currentphotoready)
这是正确的代码。我错误地将调整大小的图像存储在第 6 行。
我无法将照片放大并放入标签中。
def displayimage(self, _event=None):
if self.videopath != "" and self.txtsequenceframe.get() != "":
# Placing the lable in a different location at runtime
self.photodisplay.place(width=700, height=500, x=0, y=0)
self.currentphoto = Image.open(self.framepaths[int(self.txtsequenceframe.get())])
self.currentphoto.resize((700, 500), Image.ANTIALIAS)
self.currentphotoready = ImageTk.PhotoImage(self.currentphoto)
self.photodisplay.config(image=self.currentphotoready)
我搜索过这个主题,但他们创建了一个新标签并将图像放入其中。实际上我想多次更改该图像。谁能帮我解决这个错误?
def displayimage(self, _event=None):
if self.videopath != "" and self.txtsequenceframe.get() != "":
# Placing the lable in a different location at runtime
self.photodisplay.place(width=700, height=500, x=0, y=0)
self.currentphoto = Image.open(self.framepaths[int(self.txtsequenceframe.get())])
self.currentphoto = self.currentphoto.resize((700, 500), Image.ANTIALIAS)
self.currentphotoready = ImageTk.PhotoImage(self.currentphoto)
self.photodisplay.config(image=self.currentphotoready)
这是正确的代码。我错误地将调整大小的图像存储在第 6 行。