4 ms·
I've been using this in a Rails app to detect duplicate image uploads for years. It works really well. https://github.com/westonplatter/phashion https://githu
by duffyjp 5y ago
I've been using this in a Rails app to detect duplicate image uploads for years. It works really well.
https://github.com/westonplatter/phashion https://github.com/westonplatter/phashion
- dchuk 5y agoat 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.
- edge17 5y agoYea, i've used phashs before to find duplicates in image datasets for training neural nets. Mainly as a high level method for cleaning up large image sets.