如何在python中替换图像? [英] how to displace an image in python?
本文介绍了如何在python中替换图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的图像尺寸为400 * 200. 我的镜框尺寸为400 * 300.
I have an image size 400*200. I have a frame size 400* 300.
我想将图像放在框架的中央.那就是我的图像坐标(0,0)从帧坐标(0,50)开始.
I want to put the image in the center of frame. That is my image cordinate (0,0) starts with the frame cordinates (0,50).
推荐答案
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.)
这篇关于如何在python中替换图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文