我正在Windows 7计算机上使用ImageMagick 7.0.8-27 Q16 x64 2019-02-09和Wand 0.5.1。
我想在背景图像上覆盖具有透明背景的文本图像。
wand.drawing.Drawing.composite()为每个复合运算符创建完全相同的灰度图像。
#!/usr/bin/env python
import collections.abc
from wand.image import Image, COMPOSITE_OPERATORS
from wand.drawing import Drawing
wand_imageBackdrop = Image(filename='c:\\temp\\backdrop.png')
wand_imageOverlay = Image(filename='c:\\temp\\overlay.png')
for strCompositeOperator in COMPOSITE_OPERATORS:
wand_imageBackdropClone = wand_imageBackdrop.clone()
wand_imageOverlayClone = wand_imageOverlay.clone()
with Drawing() as draw:
draw.composite(operator=strCompositeOperator, left=0, top=0,
width=1080, height=1050, image=wand_imageOverlayClone)
draw(wand_imageBackdropClone)
wand_imageBackdropClone.save(filename='C:\\Temp\\composite_test_' + \
strCompositeOperator + '.png')
wand_imageBackdropClone.close()
wand_imageOverlayClone.close()
wand_imageBackdrop.close()
wand_imageOverlay.close()
有人可以阐明这一点吗?有什么办法可以解决这个问题?
以下StackOverflow帖子阐明了此问题。
Python wand: composite image with transparency
image composite result incorrect using python wand
使用Image.composite_channel来正确地将图像透明地覆盖在背景图像上吗?