file-setup/merge_images
Stephan Porada c67f1defb8 Test
2020-01-22 14:25:03 +01:00

40 lines
1.0 KiB
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.makedirs(os.path.join(output_dir, 'testfile.txt'))
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()