r/Python • • Feb 17 '26

Discussion [ Removed by moderator ]

[removed] — view removed post

47 Upvotes

33 comments sorted by

View all comments

Show parent comment

0

u/hdw_coder Feb 18 '26

Good point — HEIC↔JPEG is one of the trickier cases because the codec artifacts differ enough that perceptual hashes can drift more than expected (especially on foliage/texture).

In my current version they’re treated format-agnostically: load → EXIF transpose → thumbnail → multi-hash (dHash/pHash/wHash [+ colorhash]) with conservative thresholds + corroboration. Many HEIC/JPEG pairs still match, but some will miss if Hamming distances cross thresholds.

 The next improvement I’m considering is a ‘format-crossing tolerance band’. If one file is HEIC and the other is JPEG, allow a slightly higher dHash distance only if pHash+wHash corroborate strongly (and optionally run SSIM on borderline pairs). That boosts recall for iOS export duplicates without loosening the whole system and increasing false positives. Proposing concrete threshold numbers for a HEIC/JPEG pass (safe defaults) would be difficult as the values depend on hash_size, thumbnail size, and whether you’re using ImageOps.exif_transpose().