file-setup/merge_images

39 lines
988 B
Plaintext
Raw Normal View History

2020-01-07 14:13:10 +00:00
#!/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):
2020-01-08 12:48:38 +00:00
os.makedirs(output_dir, exist_ok=True)
os.system('ls -v {i}/*.* >> {i}file_list.txt'.format(i=input_dir))
2020-01-22 13:25:03 +00:00
os.system('convert @{i}/file_list.txt {o}/combined.tiff'.format(i=input_dir,
o=output_dir))
2020-01-07 14:13:10 +00:00
def main():
args = parse_arguments()
merge_images(args.input_dir, args.output_dir)
if __name__ == '__main__':
main()