summaryrefslogtreecommitdiff
path: root/check/commands/phash/load.py
diff options
context:
space:
mode:
Diffstat (limited to 'check/commands/phash/load.py')
-rw-r--r--check/commands/phash/load.py23
1 files changed, 23 insertions, 0 deletions
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)