当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python Wand composite()用法及代码示例


composite()函数使用COMPOSITE_OPERATORS在绘制对象图像的顶部渲染图像。必须为合成图像指定目标的上,左,宽和高值。

用法: wand.drawing.composite(image, left, top, operator, arguments, gravity)

参数:

参数 输入类型 描述
image wand.image.Image 放置在当前图像上的图像
left numbers.Integral 放置图片的X坐标
top numbers.Integral 图像放置的y坐标
operator basestring 影响合成物如何应用到图像的运算符。
arguments basestring 作为几何字符串或逗号分隔值给出的附加数字。 ‘blend’,‘displace’,‘dissolve’和‘modulate’运算符需要此设置。
gravity basestring 根据GRAVITY_TYPES的重力值计算上下左右的值。

以下是COMPOSITE_OPERATORS的列表:

(‘undefined’, ‘alpha’, ‘atop’, ‘blend’, ‘blur’, ‘bumpmap’, ‘change_mask’, ‘clear’, ‘color_burn’, ‘color_dodge’, ‘colorize’, ‘copy_black’, ‘copy_blue’, ‘copy’, ‘copy_cyan’, ‘copy_green’, ‘copy_magenta’, ‘copy_alpha’, ‘copy_red’, ‘copy_yellow’, ‘darken’, ‘darken_intensity’, ‘difference’, ‘displace’, ‘dissolve’, ‘distort’, ‘divide_dst’, ‘divide_src’, ‘dst_atop’, ‘dst’, ‘dst_in’, ‘dst_out’, ‘dst_over’, ‘exclusion’, ‘hard_light’, ‘hard_mix’, ‘hue’, ‘in’, ‘intensity’, ‘lighten’, ‘lighten_intensity’, ‘linear_burn’, ‘linear_dodge’, ‘linear_light’, ‘luminize’, ‘mathematics’, ‘minus_dst’, ‘minus_src’, ‘modulate’, ‘modulus_add’, ‘modulus_subtract’, ‘multiply’, ‘no’, ‘out’, ‘over’, ‘overlay’, ‘pegtop_light’, ‘pin_light’, ‘plus’, ‘replace’, ‘saturate’, ‘screen’, ‘soft_light’, ‘src_atop’, ‘src’, ‘src_in’, ‘src_out’, ‘src_over’, ‘threshold’, ‘vivid_light’, ‘xor’, ‘stereo’)



输入图像:
图片#1:

图片2:

范例1:

from wand.image import Image, COMPOSITE_OPERATORS 
from wand.drawing import Drawing 
from wand.display import display 
  
gog = Image(filename ='gog.png') 
road = Image(filename ='rd.jpg') 
  
g = gog.clone() 
r = road.clone() 
with Drawing() as draw:
    # composite image with color_burn operator 
    draw.composite(operator ='color_burn', left = 20, top = 30, 
                   width = r.width, height = r.height, image = r) 
    draw(g) 
    g.save(filename ="colorburn.png") 
    display(g)

输出:

范例1:

from wand.image import Image, COMPOSITE_OPERATORS 
from wand.drawing import Drawing 
from wand.display import display 
  
gog = Image(filename ='gog.png') 
road = Image(filename ='rd.jpg') 
  
g = gog.clone() 
r = road.clone() 
with Drawing() as draw:
    # composite image with dissolve operator 
    draw.composite(operator = 'luminize', left = 20, top = 30, 
                   width = g.width, height = g.height, image = g) 
    draw(r) 
    r.save(filename ="dissolve.png") 
    display(r)

输出:




相关用法


注:本文由纯净天空筛选整理自RahulSabharwal大神的英文原创作品 Wand composite() function in Python。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。