繁体   English   中英

魔杖:Image.composite将bg-image变成黑色

[英]Wand: Image.composite turns bg-image black

我有个问题。 以下代码可以正常工作,并且将两个图像合并在一起。 但是最终构图中的背景图像是完全黑色的。

任何猜测,这是什么问题?

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)

尝试删除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")

output.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)

暂无
暂无

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

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