gpt4 book ai didi

python - 使用 Wand 并排堆叠两个图像

转载 作者:行者123 更新时间:2023-12-03 09:08:12 26 4
gpt4 key购买 nike

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

最佳答案

您还可以使用 smush() 并在图像之间设置可选间距,并且:

  • stacked=True 用于垂直(一个在另一个之上)堆叠,或
  • stacked=False 用于并排堆叠。

from wand.image import Image

im = Image(filename="rose:")
with im as output:
output.sequence.append(im)
output.sequence.append(im)
output.smush(True, 5)
output.save(filename='result.png')

enter image description here

如果您不希望图像之间有任何间距,请设置 offset=0 或仅使用 concat() 而不是 smush() 但以完全相同的方式。

关于python - 使用 Wand 并排堆叠两个图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45203059/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com