mnrl
mnrl

Reputation: 1705

PIL paste image without blur

I want to paste an image into a single coloured background using PIL but some blures and noises appear around pasted photo like this:

enter image description here

(Zoom photo to see noises. I think it is due from Antialiasing) But I want to paste with sharp boundaries like here :

enter image description here

I am using this codes for paste:

my_image.convert('RGBA')
background = Image.new("RGBA", (background_size), background_color)
background.paste( my_image, (coordinates), my_image )
background.save("result.jpg")

What sholud i do for pasting with sharp boundaries? Thanks.

Upvotes: 1

Views: 1180

Answers (1)

Kevin
Kevin

Reputation: 76254

jpg is a lossy format, so it may blur your image or add noise, in order to save memory. Use a lossless format like png instead:

background.save("result.png")

Upvotes: 3

Related Questions