Near-uniform images (sand close-ups, solid-color shots, blank frames)
have almost no gradient transitions so their dHash has very few set bits.
These match many unrelated photos because "low contrast ≈ low contrast."
- Skip photos whose pHash has <8 or >56 set bits out of 64 before
comparing — they can't be reliably compared by dHash
- Lower default threshold 5 → 3 (≤3 differing bits = genuinely near-
identical, e.g. same photo saved at different compression levels)
- Report "N compared" in scan result so skipped photos are visible
Run "Scan library" to replace existing pairs with clean results.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The union-find algorithm caused transitivity chains: A≈B and B≈C merged
A, B, C into one group even if A and C were completely different photos,
producing the 5000+ "duplicate" groups that were wrong.
- getGroups now returns individual pairs (2 photos each) — what was
actually flagged by the pHash comparison, no chaining
- scan() clears all existing pairs on each run so the result exactly
matches the current threshold (no stale loose pairs from prior scans)
- Default dedupe_threshold lowered from 10 → 5 (fewer false positives;
distance ≤5 means the images are genuinely near-identical)
Run "Scan library" once to replace the old results with clean pairs.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Replace BigInt hammingDistance with 32-bit popcount — safer (no throw
on malformed hashes) and ~10× faster
- Make scan() async with setImmediate chunking so the event loop stays
responsive on large libraries
- Batch getGroups() photo lookup in slices of 900 to stay under SQLite's
999-variable limit
- Add POST /api/duplicates/keep-best endpoint: scores by resolution then
filesize, soft-deletes the losers, dismisses the pair
- DuplicateGroup: green "Keep" badge on the best photo, green "Keep best"
button in footer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Settings panel (⚙ in header):
- Watch Folders: add/remove paths, toggle enabled; worker polls every 30s
and calls watcher.add/unwatch without restart
- Ingestion: thumb/preview size and quality, applied per-file at ingest time
- Duplicate Detection: configurable Hamming distance threshold
- Danger Zone: clear all dismissed duplicate pairs
Multi-folder scanning:
- watch_folders table replaces single PHOTO_DIR env var
- PHOTO_DIR env var seeds the first entry on startup
- settings table with defaults for all tunable values
- Worker reads settings from DB on each drain cycle so changes are live
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>