所以我试图在较大图像的角落添加一个小图像。
width, height = original_image.size
filename = os.path.join("E:\\", "Smile.png")
logo = PIL.Image.open(filename)
# Get the smile ready for pasting
logo2 = logo.convert('RGBA')
w = width/8
h = height/8
Smile = logo2.resize((w, h))
x = 7 * (width/8)
y = 7 * (height/8)
original_image2 = original_image.convert('RGBA')
result = original_image2.paste(Smile, (x,y), mask=Smile)
'''result2 = result.convert('RGBA')'''
return result
答案 0 :(得分:1)
这是您的错误:
result = original_image2.paste(Smile, (x,y), mask=Smile)
paste
变异 original_image2
并返回None
。要解决此问题,请删除作业并直接使用original_image2
。