且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在python中替换图像?

更新时间:2023-02-19 14:30:35

frame= Image.new(image.mode, (400, 300))
frame.paste(image, (0, 50))

(如果要构图的图像具有要保留的透明蒙版,则为frame.paste(image, (0, 50), image).如果默认值不是您想要的,则将第三个参数传递给Image.new来设置帧的背景色.)

(frame.paste(image, (0, 50), image) if the image to be framed has a transparency mask you want to keep. And pass a third parameter to Image.new to set the background colour of the frame if the default isn't what you want.)