纵向拼接
from PIL import Image
def image_splicing(pic01, pic02):
with Image.open(pic01) as img_01, /
Image.open(pic02) as img_02:
img1_size, img2_size = img_01.size, img_02.size
base_point = max([img1_size[0], img2_size[0]])
target = Image.new('RGB', (base_point, img1_size[1] + img2_size[1]), (255, 255, 255)) # 创建背景为白色的空图片
target.paste(img_01) # 以坐标(0,0)为基准粘贴第一张图片
target.paste(img_02, (0, img1_size[1])) # 以坐标(0,第一张图片的高)为基准粘贴第二张图片
# target.show()
save_path = 'D:/image_marge.png'
target.save(save_path)
return save_path
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/273004.html