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 hei
(
image=None, image_path=None, width=None, height=None, closeAfter=False
)
| 138 | |
| 139 | @staticmethod |
| 140 | def getPhotoImage( |
| 141 | image=None, image_path=None, width=None, height=None, closeAfter=False |
| 142 | ): |
| 143 | """ |
| 144 | Retorna um objeto da classe PIL.ImageTk.PhotoImage de uma imagem e as imagens criadas de PIL.Image |
| 145 | (photoImage, new, original) |
| 146 | |
| 147 | @param image: Instância de PIL.Image.open |
| 148 | @param image_path: Diretório da imagem |
| 149 | @param width: Largura da imagem |
| 150 | @param height: Altura da imagem |
| 151 | @param closeAfter: Se True, a imagem será fechada após ser criado um PhotoImage da mesma |
| 152 | """ |
| 153 | |
| 154 | if not image: |
| 155 | if not image_path: |
| 156 | return |
| 157 | |
| 158 | # Abre a imagem utilizando o caminho dela |
| 159 | image = openImage(image_path) |
| 160 | |
| 161 | # Será redimesionada a imagem somente se existir um width ou height |
| 162 | if not width: |
| 163 | width = image.width |
| 164 | if not height: |
| 165 | height = image.height |
| 166 | |
| 167 | # Cria uma nova imagem já redimensionada |
| 168 | newImage = image.resize([width, height]) |
| 169 | |
| 170 | # Cria um photoImage |
| 171 | photoImage = PhotoImage(newImage) |
| 172 | |
| 173 | # Se closeAfter for True, ele fecha as imagens |
| 174 | if closeAfter: |
| 175 | # Fecha a imagem nova |
| 176 | newImage.close() |
| 177 | newImage = None |
| 178 | |
| 179 | # Fecha a imagem original |
| 180 | image.close() |
| 181 | image = None |
| 182 | |
| 183 | # Retorna o PhotoImage da imagem,a nova imagem que foi utilizada e a imagem original |
| 184 | return photoImage, newImage, image |
| 185 | |
| 186 | def jumps(self, event=None): |
| 187 | """ |