file-setup/merge_images
2020-01-27 13:48:24 +01:00

39 lines
989 B
Python
Executable File

#!/usr/bin/env python3.5
# coding=utf-8
"""
merge_images
Usage: For usage instructions run with option --help
Author: Stephan Porada <sporada@uni-bielefeld.de>
"""
import os
import argparse
def parse_arguments():
parser = argparse.ArgumentParser(description='Merges given input images '
'into one multipage tiff.')
parser.add_argument('-i', dest='input_dir', required=True)
parser.add_argument('-o', dest='output_dir', required=True)
return parser.parse_args()
def merge_images(input_dir, output_dir):
os.makedirs(output_dir, exist_ok=True)
os.system('ls -v {i}/*.* >> {i}/file_list.txt'.format(i=input_dir))
os.system('convert @{i}/file_list.txt {o}/combined.tiff'.format(i=input_dir,
o=output_dir))
def main():
args = parse_arguments()
merge_images(args.input_dir, args.output_dir)
if __name__ == '__main__':
main()