import PIL.Image as Image
import os
toImage = Image.new('RGB', (850 * 8, 1100)) # 构造图片的宽和高,如果图片不能填充完全会
dir_root = "./img_2"
files = os.listdir(dir_root)
count = 0
for file_name in files:
fname = os.path.join(dir_root, file_name)
fromImage = Image.open(fname)
fromImage = fromImage.resize((850, 1100))
toImage.paste(fromImage, (850 * count, 0))
count += 1
toImage.save('ddd.jpg')
网友评论