简体   繁体   English

PIL粘贴图像而不会模糊

[英]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: 我想使用PIL将图像粘贴到单色背景中,但是粘贴的照片周围会出现一些模糊和噪点,如下所示:

在此处输入图片说明

(Zoom photo to see noises. I think it is due from Antialiasing) But I want to paste with sharp boundaries like 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. 谢谢。

jpg is a lossy format, so it may blur your image or add noise, in order to save memory. jpg是一种有损格式,因此可能会模糊图像或增加噪点,以节省内存。 Use a lossless format like png instead: 请使用png等无损格式:

background.save("result.png")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM