我试着叠加两个图像,知道其中一个已经是透明的!你知道吗
我在网上查阅了一些已经做过的事情,以下是我发现并适应我的:
from PIL import Image
img = Image.open(fr"D:\Prog\Automatisation\Photo tu preferes quoi\signature\signature_1.png")
background = Image.open(fr"D:\Prog\Automatisation\Photo tu preferes quoi\photo_1\oui_1.png")
background.paste(img, (0, 0), new_img)
background.save('how_to_superimpose_two_images_01.png',"PNG")
from PIL import Image
img = Image.open(fr"D:\Prog\Automatisation\Photo tu preferes quoi\signature\signature_1.png")
new_image = Image.new("RGBA", img.size, "WHITE")
background = Image.open(fr"D:\Prog\Automatisation\Photo tu preferes quoi\photo_1\oui_1.png")
background.paste(img, (0, 0), new_img)
background.save('how_to_superimpose_two_images_01.png',"PNG")
我的透明图像被很好地放置在我的另一个图像的前面,但是透明部分变成了绿色,因此隐藏了另一个图像
我该怎么修?你知道吗
经过一番努力,我终于成功了!(我写这封信是为了下一个为之奋斗的人!)你知道吗
使图像透明的函数:(这里,所有的黑色像素都是透明的,您当然可以在那里更改此值)
def透明\u 1(myimage):
覆盖两个图像的函数:
def SUPERPASER(左,右):#左=前,右=背景
以及调用函数的程序:
相关问题 更多 >
编程相关推荐