PIL:如何放大图像并将其放入标签中?

问题描述

我无法放大照片并放入标签中。

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行。

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...