[英]Stack two images side by side using Wand
How do I stack two images side by side, in wand (python)? 如何以魔杖(python)并排堆叠两个图像? Composite method is available, but it puts one image on top of another. 复合方法是可用的,但是它将一个图像放在另一个图像之上。 I want something like numpy.vstack . 我想要像numpy.vstack这样的东西。
The wand.image.Image.composite
method accepts top
& left
parameters. wand.image.Image.composite
方法接受top
和left
参数。 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
. 当然,您也许可以简化上面的示例,或者使用wand.api.library
实现MagickAppendImage
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.