def getPhotoImage(image=None, image_path=None, width=None, height=None, closeAfter=False): """ Retorna um objeto da classe PIL.ImageTk.PhotoImage de uma imagem e as imagens criadas de PIL.Image (photoImage, new, original) @param image: Instância de PIL.Image.open @param image_path: Diretório da imagem @param width: Largura da imagem @param height: Altura da imagem @param closeAfter: Se True, a imagem será fechada após ser criado um PhotoImage da mesma """ if not image: if not image_path: return image = openImage(image_path) if not width: width = image.width if not height: height = image.height newImage = image.resize([width, height]) photoImage = PhotoImage(newImage) if closeAfter: newImage.close() newImage = None image.close() image = None return photoImage, newImage, image
def getPhotoImage(image=None, image_path=None, width=None, height=None, closeAfter=False): """ Retorna um objeto da classe PIL.ImageTk.PhotoImage de uma imagem e as imagens criadas de PIL.Image (photoImage, new, original) @param image: Instância de PIL.Image.open @param image_path: Diretório da imagem @param width: Largura da imagem @param height: Altura da imagem @param closeAfter: Se True, a imagem será fechada após ser criado um PhotoImage da mesma """ if not image: if not image_path: return # Abre a imagem utilizando o caminho dela image = openImage(image_path) # Será redimesionada a imagem somente se existir um width ou height if not width: width = image.width if not height: height = image.height # Cria uma nova imagem já redimensionada newImage = image.resize([width, height]) # Cria um photoImage photoImage = PhotoImage(newImage) # Se closeAfter for True, ele fecha as imagens if closeAfter: # Fecha a imagem nova newImage.close() newImage = None # Fecha a imagem original image.close() image = None # Retorna o PhotoImage da imagem,a nova imagem que foi utilizada e a imagem original return photoImage, newImage, image
def getPhotoImage(image=None, image_path=None, width=None, height=None, closeAfter=False): if not image: if not image_path: return image = openImage(image_path) if not width: width = image.width if not height: height = image.height newImage = image.resize([width, height]) photoImage = PhotoImage(newImage) if closeAfter: newImage.close() newImage = None image.close() image = None return photoImage, newImage, image