Open In App

Wand composite() function in Python

Last Updated : 11 May, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

The composite() function renders an image on top of the drawing subject image using COMPOSITE_OPERATORS. A compositing image must be given with a destination top, left, width, and height values.

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

Parameters :

Parameter Input Type Description
image wand.image.Image the image placed over the current image
left numbers.Integral the x-coordinate where image will be placed
top numbers.Integral the y-coordinate where image will be placed
operator basestring the operator that affects how the composite is applied to the image.
arguments basestring Additional numbers given as a geometry string, or comma delimited values. This is needed for ‘blend’, ‘displace’, ‘dissolve’, and ‘modulate’ operators.
gravity basestring Calculate the top & left values based on gravity value from GRAVITY_TYPES.

The following is the list of 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’)

Input Images:
Image #1:

Image #2:

Example #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)


Output :

Example #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)


Output:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads