繁体   English   中英

使用魔杖并排堆叠两个图像

[英]Stack two images side by side using Wand

如何以魔杖(python)并排堆叠两个图像? 复合方法是可用的,但是它将一个图像放在另一个图像之上。 我想要像numpy.vstack这样的东西。

wand.image.Image.composite方法接受topleft参数。 并排合成图像没有太多的努力...

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")

堆栈

...或堆积...

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")

垂直堆栈

当然,您也许可以简化上面的示例,或者使用wand.api.library实现MagickAppendImage

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM