我们从Python开源项目中,提取了以下9个代码示例,用于说明如何使用PIL.Image.show()。
def _show(image, title): """Helper for the Image.show method.""" class UI(tkinter.Label): def __init__(self, master, im): if im.mode == "1": self.image = BitmapImage(im, foreground="white", master=master) else: self.image = PhotoImage(im, master=master) tkinter.Label.__init__(self, master, image=self.image, bg="black", bd=0) if not tkinter._default_root: raise IOError("tkinter not initialized") top = tkinter.Toplevel() if title: top.title(title) UI(top, image).pack()
def _show(image, title): """Helper for the Image.show method.""" class UI(tkinter.Label): def __init__(self, master, im): if im.mode == "1": self.image = BitmapImage(im, foreground="white", master=master) else: self.image = PhotoImage(im, master=master) tkinter.Label.__init__(self, master, image=self.image, bg="black", bd=0) if not tkinter._default_root: raise IOError("tkinter not initialized") top = tkinter.Toplevel() if title: top.title(title) UI(top, image).pack() # End of file
def getimage(photo): """Copies the contents of a PhotoImage to a PIL image memory.""" photo.tk.call("PyImagingPhotoGet", photo) # -------------------------------------------------------------------- # Helper for the Image.show method.
def show(self): """Displays the image (mainly for debugging). Check the PIL Image.show() documentation to find out more.""" self.__image.show()
def get_image(file_handle): # Note: # 1. need convert to 'RGB' for some (transparent) format image cannot be shown using PhotoImage # don't know why, but those image actually can be shown by Image itself (usg Image.show) # 2. use file_handle instead of filename, for in Windows, Image.open() seems not close its # handle upon IOError, and thus, induces an unexpected file lock return Image.open(file_handle).convert("RGB")