From d3c3c5f1e4524eb055bb1f92189ed12fddd1370d Mon Sep 17 00:00:00 2001 From: rrr-marble Date: Thu, 1 Jul 2021 20:55:30 +0300 Subject: [PATCH] add: photo importer util, prototype --- util/import_photos.py | 61 +++++++++++++++++++++++++++++++++++++++++++ util/requirements.txt | 2 ++ 2 files changed, 63 insertions(+) create mode 100644 util/import_photos.py create mode 100644 util/requirements.txt diff --git a/util/import_photos.py b/util/import_photos.py new file mode 100644 index 0000000..d405f8e --- /dev/null +++ b/util/import_photos.py @@ -0,0 +1,61 @@ +# Third-party +from wand.image import Image +import filetype + +# Built-in +from os import path +from sys import argv, stderr +from shutil import move + +# update database residing here +DB_LOCATION = "photovoter.dblite" +# place compressed images here +DEST_STRUNK = "image/" + + +def usage(): + """Brief usage explanation""" + print("USAGE: ./{name} /path/to/images".format(name=argv[0]), file=stderr) + + +def process_pictures(): + """Process images from the base directory in the first command line argument. + Place the resized copies to DEST_STRUNK and + move the originals to DEST_ORIGINAL. + Return a dict for each image processed for database collection. + """ + # walk every pic + # process it with imagemagick + # move them to the processed folder + # update the database + pass + + +def update_database(): + """Append new image information to the existing database + or create a new one, if it does not exist yet + """ + # make sure the database exists + # insert new pictures to the image table + pass + + +def check_database(): + """Check if there is a database at DB_LOCATION. + Just return if there is. If not, create a new one. + """ + # db exists? + # make one + pass + + +def main(): + if len(argv) != 2: + usage() + exit(1) + + # process each pic and add it to the database + + +if __name__ == "__main__": + main() diff --git a/util/requirements.txt b/util/requirements.txt new file mode 100644 index 0000000..12350b0 --- /dev/null +++ b/util/requirements.txt @@ -0,0 +1,2 @@ +filetype==1.0.7 +Wand==0.6.6