1

我有个问题。以下代码确实有效,它结合了两个图像。但是最终合成中的背景图像是完全黑色的。

任何猜测,这里有什么问题?

from wand.image import Image

with Image(filename=bgimage) as back:
    with Image(filename=qrcode) as front:
        with Image(width=back.width, height=back.height) as new_image:
            new_image.composite(front, left=1000, top=900)
            new_image.save(filename=qr_output)
4

1 回答 1

0

尝试删除该new_image部分,并简化一切。

with Image(filename="wizard:") as back:
  with Image(filename="rose:") as front:
    back.composite(front,
                   top=back.height-front.height,
                   left=back.width-front.width)
    back.save(filename="/tmp/output.png")

输出.png

如果您尝试重用back实例,请利用wand.image.Image.clone

with Image(filename=bgimage) as back:
  with Image(filename=qrcode) as front:
     with back.clone() as new_image:
       new_image.composite(front, left=1000, top=900)
       new_image.save(filename=qr_output)
于 2017-07-24T18:52:45.093 回答