mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/file-setup.git
synced 2024-12-27 11:54:19 +00:00
40 lines
1.0 KiB
Python
Executable File
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()
|