Fix path problems

This commit is contained in:
Patrick Jentsch 2020-01-27 15:52:20 +01:00
parent b0a0985c73
commit dba21fbfd7

View File

@ -10,23 +10,33 @@ Author: Stephan Porada <sporada@uni-bielefeld.de>
""" """
import os
import argparse import argparse
import os
import subprocess
def parse_arguments(): def parse_arguments():
parser = argparse.ArgumentParser(description='Merges given input images ' parser = argparse.ArgumentParser(description='Merges given input images '
'into one multipage tiff.') 'into one multipage tiff.')
parser.add_argument('-i', dest='input_dir', required=True) parser.add_argument('-i', dest='input_dir', required=True,
parser.add_argument('-o', dest='output_dir', required=True) type=os.path.abspath)
parser.add_argument('-o', dest='output_dir', required=True,
type=os.path.abspath)
return parser.parse_args() return parser.parse_args()
def merge_images(input_dir, output_dir): def merge_images(input_dir, output_dir):
os.makedirs(output_dir, exist_ok=True) try:
os.system('ls -v {i}/*.* >> {i}/file_list.txt'.format(i=input_dir)) os.mkdir(output_dir)
os.system('convert @{i}/file_list.txt {o}/combined.tiff'.format(i=input_dir, except FileExistsError:
o=output_dir)) pass
cmd = 'ls -Q -v {i}/*.* > {i}/file_list.txt'.format(i=input_dir)
subprocess.run(cmd, shell=True)
cmd = 'convert @{i}/file_list.txt {o}/combined.tif'.format(i=input_dir,
o=output_dir)
subprocess.run(cmd, shell=True)
cmd = 'rm {i}/file_list.txt'.format(i=input_dir)
subprocess.run(cmd)
def main(): def main():