feat: duplicate detection via perceptual hashing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ferdinand
2026-04-07 13:23:01 +02:00
parent bac279294f
commit 3d22b41bf2
12 changed files with 1285 additions and 0 deletions

Binary file not shown.

View File

@@ -44,3 +44,26 @@ def test_normal_image_is_neither(tmp_path):
path = make_test_image(tmp_path, color=(128, 128, 128))
assert is_overexposed(path, threshold=240) is False
assert is_underexposed(path, threshold=30) is False
from analyzer import find_duplicates
def test_identical_images_are_duplicates(tmp_path):
p1 = make_test_image(tmp_path, color=(100, 150, 200))
import shutil
p2 = tmp_path / "copy.jpg"
shutil.copy(p1, p2)
groups = find_duplicates([p1, str(p2)], threshold=0)
assert len(groups) == 1
assert len(groups[0]) == 2
def test_different_images_are_not_duplicates(tmp_path):
from PIL import Image
p1 = make_test_image(tmp_path, color=(0, 0, 0))
img = Image.new("RGB", (100, 100), color=(255, 0, 0))
p2 = tmp_path / "red.jpg"
img.save(p2)
groups = find_duplicates([p1, str(p2)], threshold=0)
assert len(groups) == 0