From cbf5362588c4ddb8dccc8790a97fa213eb0b494f Mon Sep 17 00:00:00 2001 From: rrr-marble Date: Thu, 1 Jul 2021 22:14:28 +0300 Subject: [PATCH] add: save the originals too --- util/import_photos.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/util/import_photos.py b/util/import_photos.py index 926c350..d5ce5cf 100644 --- a/util/import_photos.py +++ b/util/import_photos.py @@ -3,14 +3,16 @@ from wand.image import Image import filetype # Built-in -from os import path +from os import path, walk from sys import argv, stderr from shutil import move # update database residing here DB_LOCATION = "photovoter.dblite" -# place compressed images here +# place compressed images here (needs to exist) DEST_STRUNK = "image/" +# move originals here (needs to exist) +DEST_ORIGINAL = "original/" def usage(): @@ -29,6 +31,7 @@ def process_pictures(): # Ignore any nested directories (root, _, filenames) = next(walk(argv[1], topdown=True), (None, None, [])) for filename in filenames: + # FIXME:what if picture with the same name already exists? # skip any non-image files if not filetype.image_match(path.join(root, filename)): continue @@ -45,6 +48,10 @@ def process_pictures(): # move them to the processed folder cloned.save(filename=path.join(DEST_STRUNK, filename)) + # move the originals out of the working directory + # Q: do we strip exif from originals? + move(path.join(root, filename), DEST_ORIGINAL) + # update the database pass