3 ms·
at a high level, how did you implement this? Are you storing the phash of each image in the database and then when new images are uploaded, do you query the dat
by dchuk 5y ago
at a high level, how did you implement this? Are you storing the phash of each image in the database and then when new images are uploaded, do you query the database to see if any matches return? If so, how does that query actually work?
Or are you using this to ensure there’s no duplicates in a batch of images being uploaded?
- duffyjp 5y agoYep, I store each hash in the DB. The ruby gem has a mechanism to test similarity to your existing hashes with a threshold so small edits still match. It's surprisingly fast too, checking against every existing hash doesn't noticeably slow down the upload. I think it's a bitwise compare, but admittedly I set that up a long time ago so I'm foggy on the details. Originally I added it because I wanted a way to automatically find the full quality image from my archive and replace the aggressively scaled down versions I used to use. Back in 2003 100KB was considered pretty big for a photo, but now it looks like garbage. I never found time to finish that part of it.