feat: duplicate detection via perceptual hashing
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
BIN
tests/__pycache__/__init__.cpython-314.pyc
Normal file
BIN
tests/__pycache__/__init__.cpython-314.pyc
Normal file
Binary file not shown.
BIN
tests/__pycache__/test_analyzer.cpython-314-pytest-8.1.1.pyc
Normal file
BIN
tests/__pycache__/test_analyzer.cpython-314-pytest-8.1.1.pyc
Normal file
Binary file not shown.
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user