Let's assume a JPG file (or any other image/video file format), that I duplicate the file, and I modify the tags on the copy. Is there a way to verify that the image inside both JPG files is actually the same? I mean, if I do a digest of both files, I will obviously get a different hash. But is there a way to extract from the JPG only the bytes representing the image, so that I can do a digest of these bytes and see that both files are actually the one and same image?
The above is in the context of trying to automate how I manage my photos, i.e. extracting photos from my phone to my pc, detecting duplicates before I back things up, etc. In case it would influence the answers, my home made tools are written in Java, sometimes using external tools like exiftool.
There are two other threads (How can I identify duplicate image files? and Consolidate photos and eliminate duplicates? [duplicate]) that appear to be duplicates, but in my opinion, they're not. Firstly, the second thread is all about Mac and about file naming conventions based on EXIF data. That is most certainly not what my question is about. As for the first thread, it asks for tools that can find duplicates. While a plethora of answers were provided, none of the tools were doing exactly what I wanted (and most were not free) except for the very last answer "Dedup-image" (which incidentally had the lowest score in that thread...). When I dug into the script, I found exactly what I wanted, and this happened to be exactly the answer provided by @Kahovius
In short, the answer from @Kahovius:
- is free
- is able to recognize that two files having different hashes (because they have different EXIF metadata) actually contain the exact same image (i.e. exact same bytes)
- can be automated (in BASH scripts for instance)
- (as a bonus) can even detect images that are duplicate when the only transformation was a lossless rotation (the actual bytes of the image are the same as the rotation is just a tag that was added to the file).
All other tools mentioned in the first thread were either not free, or would compare files as blobs (i.e. two files with same image bytes but different EXIF metadata would be seen as different), or would do some heuristics when comparing images (e.g. an image which has red eye removed could be considered duplicate of the original image). None of this is what I wanted.