本文整理汇总了Python中psd_tools.PSDImage.from_stream方法的典型用法代码示例。如果您正苦于以下问题:Python PSDImage.from_stream方法的具体用法?Python PSDImage.from_stream怎么用?Python PSDImage.from_stream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类psd_tools.PSDImage
的用法示例。
在下文中一共展示了PSDImage.from_stream方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: image_file_to_clipboard
# 需要导入模块: from psd_tools import PSDImage [as 别名]
# 或者: from psd_tools.PSDImage import from_stream [as 别名]
def image_file_to_clipboard(fileObj, is_psd=False):
'''Read an image file and write the image data into clipboard.
See http://stackoverflow.com/questions/7050448/write-image-to-windows-clipboard-in-python-with-pil-and-win32clipboard
'''
from psd_tools import PSDImage
if is_psd:
psd = PSDImage.from_stream(fileObj)
image = psd.as_PIL()
elif isinstance(fileObj, Image.Image):
image = fileObj
else:
image = Image.open(fileObj)
image_to_clipboard(image)
示例2: image_file_to_clipboard
# 需要导入模块: from psd_tools import PSDImage [as 别名]
# 或者: from psd_tools.PSDImage import from_stream [as 别名]
def image_file_to_clipboard(fileObj, is_psd=False):
'''Read an image file and write the image data into clipboard.
See http://stackoverflow.com/questions/7050448/write-image-to-windows-clipboard-in-python-with-pil-and-win32clipboard
'''
if is_psd:
psd = PSDImage.from_stream(fileObj)
image =psd.as_PIL()
else:
image = Image.open(fileObj)
sio = StringIO()
image.convert('RGB').save(sio, 'BMP')
data = sio.getvalue()[14:]
sio.close()
win32clipboard.OpenClipboard()
try:
win32clipboard.EmptyClipboard()
win32clipboard.SetClipboardData(win32clipboard.CF_DIB, data)
finally:
win32clipboard.CloseClipboard()
示例3: psd_image_factory
# 需要导入模块: from psd_tools import PSDImage [as 别名]
# 或者: from psd_tools.PSDImage import from_stream [as 别名]
def psd_image_factory(data, *args):
try:
return PSDImage.from_stream(data).as_PIL()
except Exception:
raise TypeError
示例4: psd_image_factory
# 需要导入模块: from psd_tools import PSDImage [as 别名]
# 或者: from psd_tools.PSDImage import from_stream [as 别名]
def psd_image_factory(data, *args):
return PSDImage.from_stream(data).as_PIL()