Skip to content

Commit

Permalink
Refactor --thumbnail-output as discussed in #59
Browse files Browse the repository at this point in the history
  • Loading branch information
amietn committed Mar 26, 2019
1 parent 3157f69 commit e5e9ed3
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions vcsi/vcsi.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import datetime
import os
import shutil
import subprocess
import sys
import shutil
from concurrent.futures import ThreadPoolExecutor

try:
Expand Down Expand Up @@ -1405,9 +1405,9 @@ def main():
help="Fast mode. Just make a contact sheet as fast as possible, regardless of output image quality. May mess up the terminal.",
dest="fast")
parser.add_argument(
"-to", "--thumbnail_output",
help="Save thumbnail files to output directory. If set, the thumbnail files will not be deleted after successful creation of the contact sheet.",
default="",
"-O", "--thumbnail-output",
help="Save thumbnail files to the specified output directory. If set, the thumbnail files will not be deleted after successful creation of the contact sheet.",
default=None,
dest="thumbnail_output_path"
)

Expand Down Expand Up @@ -1566,12 +1566,17 @@ def process_file(path, args):

# save selected frames of the contact sheet to the predefined location in thumbnail_output_path
thumbnail_output_path = args.thumbnail_output_path
if thumbnail_output_path != "" and os.path.isdir(thumbnail_output_path):
print("Copy thumbnails...")
if thumbnail_output_path is not None:
os.makedirs(thumbnail_output_path, exist_ok=True)
print("Copying thumbnails to {} ...".format(thumbnail_output_path))
for i, frame in enumerate(selected_frames):
print(frame.filename)
thumbnail_file_extension = frame.filename.lower().split(".")[-1]
shutil.copyfile(frame.filename, thumbnail_output_path + os.path.basename(path) + '.' + str(i).zfill(4) + '.' + thumbnail_file_extension)
thumbnail_filename = "{filename}.{number}.{extension}".format(filename=os.path.basename(path),
number=str(i).zfill(4),
extension=thumbnail_file_extension)
thumbnail_destination = os.path.join(thumbnail_output_path, thumbnail_filename)
shutil.copyfile(frame.filename, thumbnail_destination)

print("Cleaning up temporary files...")
cleanup(temp_frames)
Expand Down

0 comments on commit e5e9ed3

Please sign in to comment.