0

I want to paste one photo over another, adding a round transparency frame over the first one. I come from the following question: Previous question

tap = Image.open ("./background.png")
userImg = Image.open("./inphoto.png") 
#tap variable is image correctly loaded, the background
draw = ImageDraw.Draw(tap)
#rounded mask
backg = Image.new(userImg.mode, size, (0,0,0))
mask = Image.new("L", size, color=0)
imgD = ImageDraw.Draw(mask)
blur_radius = 2
offset = 4
offset = blur_radius * 2 + offset
imgD.ellipse((offset, offset, 125 - offset, 125 - offset), fill=255)
mask = mask.filter(ImageFilter.GaussianBlur(blur_radius)
finalImgRound = Image.composite(userImg, backg, mask=mask)
#tap variable is the background
tap.paste(finalImgRound, (50, 50))        

As you can see in the example image, the black frame continues in the image frame, and does not produce any transparency effect (the original image is square, and the code above adds the black frame, but not transparency).

enter image description here Paste with background result ---> enter image description here

(I add green backgraound below): Image BG

How can I apply the transparency in the black area?

Edited: As suggested by member's of SO. Added original picture. Remove unuseful code.

Joseph
  • 29
  • 6
  • Suggestions: Reduce your code to a [mre] (e.g. get rid of the font/text stuff). Also add links to all the images involved. – martineau Sep 14 '21 at 23:34

0 Answers0