mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/file-setup.git
synced 2024-12-26 19:34:19 +00:00
40 lines
978 B
Plaintext
40 lines
978 B
Plaintext
|
#!/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.system('mkdir {}'.format(output_dir))
|
||
|
os.system('ls -v {}/*.* >> file_list.txt'.format(input_dir))
|
||
|
os.system('convert @file_list.txt {}/combined.tiff'.format(output_dir))
|
||
|
os.system('cat "file_list.txt" | xargs rm')
|
||
|
os.system('rm file_list.txt')
|
||
|
|
||
|
|
||
|
def main():
|
||
|
args = parse_arguments()
|
||
|
merge_images(args.input_dir, args.output_dir)
|
||
|
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
main()
|