From 79f0e696f3f6067a0841a37404fb546dedaa07cb Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 15 Apr 2019 16:26:03 +0200 Subject: cli suite working --- check/commands/phash/load.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 check/commands/phash/load.py (limited to 'check/commands/phash/load.py') diff --git a/check/commands/phash/load.py b/check/commands/phash/load.py new file mode 100644 index 0000000..ce9ceef --- /dev/null +++ b/check/commands/phash/load.py @@ -0,0 +1,23 @@ +""" +Loop over a directory of images + - Compute their phashes + - Optionally upload them to s3? +""" + +import click +import glob + +from app.models.sql_factory import add_phash_by_filename + +@click.command() +@click.option('-i', '--input', 'opt_input_glob', + required=True, + help="File glob to add -- e.g. '../docs/images/*.jpg'") +@click.pass_context +def cli(ctx, opt_input_glob): + """ + Add a directory of images + """ + print('Adding a directory...') + for fn in glob.iglob(opt_input_glob): + add_phash_by_filename(fn) -- cgit v1.2.3-70-g09d2