From c8df1b6f5031a030fea31012e096c14fb2fddf55 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Fri, 26 Apr 2019 04:07:15 +0200 Subject: dump dedupe output --- check/commands/phash/dedupe.py | 10 +++++++++- client/app.js | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/check/commands/phash/dedupe.py b/check/commands/phash/dedupe.py index 2e99f62..28266f4 100644 --- a/check/commands/phash/dedupe.py +++ b/check/commands/phash/dedupe.py @@ -9,18 +9,22 @@ import glob from PIL import Image from app.utils.im_utils import compute_phash +from app.utils.file_utils import write_json, sha256 @click.command() @click.option('-i', '--input', 'opt_input_glob', required=True, help="Input glob to search -- e.g. '../docs/images/*.jpg'") +@click.option('-o', '--output', 'opt_output_fn', + required=False, + help="Input glob to search -- e.g. '../docs/images/*.jpg'") @click.option('-t', '--threshold', 'opt_threshold', required=True, default=6, type=int, help="Threshold for PHash hamming distance comparison (0-64, default=6)") @click.pass_context -def cli(ctx, opt_input_glob, opt_threshold): +def cli(ctx, opt_input_glob, opt_output_fn, opt_threshold): """ Dedupe a folder of images """ @@ -31,10 +35,14 @@ def cli(ctx, opt_input_glob, opt_threshold): im = Image.open(fn).convert('RGB') phash = compute_phash(im) if is_phash_new(fn, phash, seen, opt_threshold): + hash = sha256(fn) seen.append({ + 'sha256': hash, 'phash': phash, 'fn': fn, }) + if opt_output_fn: + write_json(seen, opt_output_fn) print("checked {} files, found {} unique".format(total, len(seen))) def is_phash_new(fn, phash, seen, opt_threshold): diff --git a/client/app.js b/client/app.js index 96c426c..ba77be6 100644 --- a/client/app.js +++ b/client/app.js @@ -89,7 +89,7 @@ export default class PhashApp extends Component { ) } - console.log(closest_match) + const { ext, phash, score, sha256 } = closest_match return (
-- cgit v1.2.3-70-g09d2