本文整理汇总了Python中pgmagick.Image.zoom方法的典型用法代码示例。如果您正苦于以下问题:Python Image.zoom方法的具体用法?Python Image.zoom怎么用?Python Image.zoom使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pgmagick.Image
的用法示例。
在下文中一共展示了Image.zoom方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_test_data
# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import zoom [as 别名]
def create_test_data(self):
im = Image(root('resources', 'color_circle.png').encode('utf-8'))
if self.mode == 'RGB':
im.type(ImageType.TrueColorType)
elif self.mode == 'RGBA':
im.type(ImageType.TrueColorMatteType)
elif self.mode == 'L':
im.type(ImageType.GrayscaleType)
elif self.mode in 'LA':
im.type(ImageType.GrayscaleMatteType)
else:
raise ValueError('Unknown mode: {}'.format(self.mode))
im.filterType(FilterTypes.CatromFilter)
im.zoom(Geometry(b"{}x{}!".format(self.size[0], self.size[1])))
return [im]
示例2: merge_overlay
# 需要导入模块: from pgmagick import Image [as 别名]
# 或者: from pgmagick.Image import zoom [as 别名]
def merge_overlay(self, overlay):
self.open()
overlay.open()
background_image = Image(self.image)
# remove any transparent areas around the logo
overlay_image = Image(Geometry(overlay.image.size().width() + 2, overlay.image.size().height() + 2), 'transparent')
overlay_image.composite(overlay.image, GravityType.CenterGravity, CompositeOperator.OverCompositeOp)
overlay_image.trim()
border_width = int(math.ceil(background_image.size().width() * PIconBackground.BORDER_RATIO))
overlay_image.zoom(Geometry(background_image.size().width() - (border_width * 2), background_image.size().height() - (border_width * 2)))
# we need to calculate exact position since we get 1-pixel error
# if the height of the logo is odd and using GravityType.CenterGravity
if overlay_image.size().width() + (2 * border_width) == background_image.size().width():
x = border_width
y = int(math.ceil((background_image.size().height() / 2.0) - (overlay_image.size().height() / 2.0)))
else:
x = int(math.ceil((background_image.size().width() / 2.0) - (overlay_image.size().width() / 2.0)))
y = border_width
background_image.composite(overlay_image, x, y, CompositeOperator.OverCompositeOp)
return PIcon(background_image)