Python PIL.Image 模块,show() 实例源码
我们从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, 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(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")
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。