效果图
![在这里插入图片描述](https://img-blog.csdnimg.cn/1d88499f880a46d1a81178dbcd3fa2c2.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAWl9YX0xlaQ==,size_20,color_FFFFFF,t_70,g_se,x_16#pic_center)
源码
from PIL import Image
def paste_files(file_dir):
im_list = [Image.open(file_dir + '/' + fn) for fn in listdir(file_dir) if fn.endswith('.jpg')]
new_image_width = 0
new_image_height = 0
for image in im_list:
width, height = image.size
new_image_width += width
if height > new_image_height:
new_image_height = height
board = Image.new(im_list[0].mode, (new_image_width, new_image_height))
width_pos = 0
for image in im_list:
board.paste(image, box=(width_pos, 0))
width, height = image.size
width_pos += width
board.save('paste.jpg')