将多张图像合并为一张图像

时间:2020-07-23 08:10:50

标签: python

我正在寻找帮助,尝试使用python脚本将属于一个用户的多个图像合并为一个图像文件。例如,用户12568有7张图像,我正尝试将其合并为一个文件,该文件中将垂直包含1-7页。超过10万名以上的用户也需要申请同样的内容

FYI

1 个答案:

答案 0 :(得分:0)

一种不错的方法是使用imageio。

import imageio
import os

path = "C:/path_to_folder/"
image_path_list = os.listdir(path)

with imageio.get_writer("new_image.tif") as new_image:
    for image_path in image_path_list:
        image = imageio.imread(path+image_path)
        new_image.append_data(image)

这将创建一个tif文件,每个图像包含一个页面。

请注意,使用此代码文件夹仅应包含图像。