我想使用 PIL 将图像粘贴到单色背景中,但粘贴的照片周围出现一些模糊和噪点,如下所示:
(缩放照片以查看噪音。我认为这是由于抗锯齿造成的)但我想粘贴清晰的边界,如下所示:
我使用此代码进行粘贴:
my_image.convert('RGBA')
background = Image.new("RGBA", (background_size), background_color)
background.paste( my_image, (coordinates), my_image )
background.save("result.jpg")
粘贴边界清晰时应该怎么做? 谢谢。
最佳答案
jpg 是一种有损格式,因此它可能会模糊图像或添加噪音,以节省内存。请改用 png 等无损格式:
background.save("result.png")
关于python - PIL粘贴图像不模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18538189/