mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/file-setup.git
synced 2024-12-27 11:54:19 +00:00
Add a switch for zip functionality
This commit is contained in:
parent
4f036296d3
commit
fb14759bb9
@ -13,6 +13,7 @@ RUN apt-get update \
|
|||||||
&& apt-get install -y --no-install-recommends \
|
&& apt-get install -y --no-install-recommends \
|
||||||
imagemagick \
|
imagemagick \
|
||||||
python3.5 \
|
python3.5 \
|
||||||
|
zip \
|
||||||
&& rm -rf /var/lib/apt/lists/*
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
|
||||||
|
13
merge_images
13
merge_images
@ -22,26 +22,31 @@ def parse_arguments():
|
|||||||
type=os.path.abspath)
|
type=os.path.abspath)
|
||||||
parser.add_argument('-o', dest='output_dir', required=True,
|
parser.add_argument('-o', dest='output_dir', required=True,
|
||||||
type=os.path.abspath)
|
type=os.path.abspath)
|
||||||
|
parser.add_argument('--zip', action='store_true', default=False,
|
||||||
|
dest='zip', help='package result files in zip bundles',
|
||||||
|
required=False)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def merge_images(input_dir, output_dir):
|
def merge_images(input_dir, output_dir, zip):
|
||||||
try:
|
try:
|
||||||
os.mkdir(output_dir)
|
os.mkdir(output_dir)
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
cmd = 'ls -Q -v {i}/*.* > {i}/file_list.txt'.format(i=input_dir)
|
cmd = 'ls -Q -v {i}/*.* > {i}/file_list.txt'.format(i=input_dir)
|
||||||
subprocess.run(cmd, shell=True)
|
subprocess.run(cmd, shell=True)
|
||||||
cmd = 'convert @{i}/file_list.txt {o}/combined.tif'.format(i=input_dir,
|
cmd = 'convert @{i}/file_list.txt {o}/combined.tif'.format(i=input_dir, o=output_dir)
|
||||||
o=output_dir)
|
|
||||||
subprocess.run(cmd, shell=True)
|
subprocess.run(cmd, shell=True)
|
||||||
cmd = 'rm {i}/file_list.txt'.format(i=input_dir)
|
cmd = 'rm {i}/file_list.txt'.format(i=input_dir)
|
||||||
subprocess.run(cmd, shell=True)
|
subprocess.run(cmd, shell=True)
|
||||||
|
if zip:
|
||||||
|
cmd = 'cd {o} && zip -m combined.zip combined.tif && cd -'.format(o=output_dir)
|
||||||
|
subprocess.run(cmd, shell=True)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = parse_arguments()
|
args = parse_arguments()
|
||||||
merge_images(args.input_dir, args.output_dir)
|
merge_images(args.input_dir, args.output_dir, args.zip)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user