本文整理汇总了Python中Image.composite方法的典型用法代码示例。如果您正苦于以下问题:Python Image.composite方法的具体用法?Python Image.composite怎么用?Python Image.composite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image
的用法示例。
在下文中一共展示了Image.composite方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: composite
# 需要导入模块: import Image [as 别名]
# 或者: from Image import composite [as 别名]
def composite(image1, image2, mask):
"Create composite image by blending images using a transparency mask"
return Image.composite(image1, image2, mask)
##
# Offset image data.
# <p>
# Returns a copy of the image where data has been offset by the given
# distances. Data wraps around the edges. If yoffset is omitted, it
# is assumed to be equal to xoffset.
#
# @param image Source image.
# @param xoffset The horizontal distance.
# @param yoffset The vertical distance. If omitted, both
# distances are set to the same value.
# @return An Image object.
示例2: batch
# 需要导入模块: import Image [as 别名]
# 或者: from Image import composite [as 别名]
def batch(infolder, outfolder, watermark):
mark = Image.open(watermark)
for root, dirs, files in os.walk(infolder):
for name in files: try:
im = Image.open(join(root, name))
if im.mode != 'RGBA':
im = im.convert('RGBA')
layer = Image.new('RGBA', im.size, (0,0,0,0))
position = (im.size[0]-mark.size[0], im.size[1]-mark.size[1])
layer.paste(mark, position)
Image.composite(layer, im, layer).save( join(outfolder, name))
except Exception, (msg):
print msg
示例3: blend
# 需要导入模块: import Image [as 别名]
# 或者: from Image import composite [as 别名]
def blend(image1, image2, alpha):
"Blend two images using a constant transparency weight"
return Image.blend(image1, image2, alpha)
##
# Create composite using transparency mask.
# <p>
# Same as the <b>composite</b> function in the <b>Image</b> module.
示例4: _img_rotate
# 需要导入模块: import Image [as 别名]
# 或者: from Image import composite [as 别名]
def _img_rotate(self, im, target, degree, bgcolor = '#ffffff', destformat = None):
"""
Rotate image. The ``degree`` argument is measured clock-wise.
"""
#rotated = im.convert('RGBA').rotate(angle=360-degree)
alpha = Image.new('RGBA', im.size, bgcolor)
alpha.paste(im)
rotated = alpha.rotate(angle=360-degree, resample=Image.BILINEAR)
bg = Image.new('RGBA', im.size, bgcolor)
result = Image.composite(rotated, bg, rotated)
self._saveimage(result, target, destformat if destformat else im.format)