我的照片以NoneType的形式返回

时间:2016-02-16 18:28:30

标签: python python-imaging-library

所以我试图在较大图像的角落添加一个小图像。

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

1 个答案:

答案 0 :(得分:1)

这是您的错误:

result = original_image2.paste(Smile, (x,y), mask=Smile)

paste 变异 original_image2并返回None。要解决此问题,请删除作业并直接使用original_image2