0
如何在魔杖(python)中并排堆叠两张图像?复合方法是可用的,但它将一个图像放在另一个图像的上面。 我想要一些像numpy.vstack。使用魔杖堆叠两张图像并排使用魔杖
如何在魔杖(python)中并排堆叠两张图像?复合方法是可用的,但它将一个图像放在另一个图像的上面。 我想要一些像numpy.vstack。使用魔杖堆叠两张图像并排使用魔杖
wand.image.Image.composite
方法接受top
& left
参数。没有太多的努力,通过侧复合图像侧...
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
。
谢谢,我会检查出来。 –