mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/file-setup.git
synced 2024-12-25 19:04:18 +00:00
Fix path problems
This commit is contained in:
parent
b0a0985c73
commit
dba21fbfd7
24
merge_images
24
merge_images
@ -10,23 +10,33 @@ Author: Stephan Porada <sporada@uni-bielefeld.de>
|
||||
|
||||
"""
|
||||
|
||||
import os
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
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)
|
||||
parser.add_argument('-i', dest='input_dir', required=True,
|
||||
type=os.path.abspath)
|
||||
parser.add_argument('-o', dest='output_dir', required=True,
|
||||
type=os.path.abspath)
|
||||
return parser.parse_args()
|
||||
|
||||
|
||||
def merge_images(input_dir, output_dir):
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
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))
|
||||
try:
|
||||
os.mkdir(output_dir)
|
||||
except FileExistsError:
|
||||
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():
|
||||
|
Loading…
Reference in New Issue
Block a user