jeremy james
jeremy james

Reputation: 21

My pictures are returning as NoneType

So i am trying to add a small image to the corner of a larger image.

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

Upvotes: 1

Views: 872

Answers (1)

Steven Rumbalski
Steven Rumbalski

Reputation: 45541

Here is your error:

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

paste mutates original_image2 and returns None. To fix this get rid of the assignment and just use original_image2 directly.

Upvotes: 3

Related Questions