Reputation: 163
this is the original back image this is the original front image this is my code:
from PIL import Image
front=Image.open('/users/apple/Desktop/TMP.jpeg')
back=Image.open('/Users/apple/Desktop/原始图片/084.jpeg')
front=front.rotate(100,expand=True)
back.paste(front,(100,100))
back
this is what i get. i want a clean paste without cropping sides. can somebody help me ,thanks.
Upvotes: 4
Views: 6589
Reputation: 308520
You need to generate a mask that you can pass to paste
to exclude the new black edges.
mask = Image.new('L', front.size, 255)
front = front.rotate(100, expand=True)
mask = mask.rotate(100, expand=True)
back.paste(front, (100,100), mask)
Upvotes: 8