How do I stack two images side by side, in wand (python)? Composite method is available, but it puts one image on top of another. I want something like numpy.vstack .
The wand.image.Image.composite
method accepts top
& left
parameters. Not much effort to composite image side by side...
with Image(filename="rose:") as left:
with Image(filename="rose:") as right:
with Image(width=left.width+right.width,
height=max(left.height, right.height)) as output:
output.composite(image=left, left=0, top=0)
output.composite(image=right, left=left.width, top=0)
output.save(filename="hstack.png")
... or stacked ...
with Image(filename="rose:") as top:
with Image(filename="rose:") as bottom:
with Image(width=max(top.width, bottom.width),
height=top.height + bottom.height) as output:
output.composite(image=top, left=0, top=0)
output.composite(image=bottom, left=0, top=top.height)
output.save(filename="vstack.png")
Of course you may be able to simplify the examples above, or use wand.api.library
to implement MagickAppendImage
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.