我有一堆图片需要加上文字覆盖。我用GIMP创建了覆盖层(PNG格式,带透明度),然后尝试将其粘贴到另一张图片的顶部:
from PIL import Image
background = Image.open("hahn_echo_1.png")
foreground = Image.open("overlay_step_3.png")
background.paste(foreground, (0, 0), foreground)
background.save("abc.png")
然而,我得到的不是漂亮的黑色文本,而是这个:
在Gimp中,overlay.png看起来像这样:
所以我希望看到一些漂亮的黑色文本,而不是这个五颜六色的混乱。
有什么想法吗?我错过了一些 PIL 选项吗?
alpha_composite
吗?请参考这个答案。 - vrs