Compare images with Opus

Yesterday I read a few comments saying that Opus can’t compare images beyond their properties or available metadata. While that’s partially true, I have to say Opus is extremely extendable through scripting.
So I set out to learn a bit about image comparison. So I browsed a lot of websites on the topic and got especially interested in the discussions around the algorithms mentioned in here—including the comments.
In the end, I went with pHash. Even though dHash is often said to be the better option, in my implementation it just didn’t give the results I was hoping for.

The challenge was to develop or port some of those algorithms using pure JScript, with minimal use of third-party tools (except Opus), and ideally sticking to tools that come with Windows. Also, no temporary files allowed.

That led me to dig deeper and discover that Windows does have some (outdated) scripting capabilities for image processing. It can't convert an image to grayscale, though, so I had to come up with a manual workaround!

To keep this short, here’s a test version of a script that compares two images and shows their similarity percentage. The closer the value is to 0, the more alike the images are.

To use it, first install the script.
PhotoComparer.opusscriptinstall (5.2 KB)

Then, just select a couple of images (at least two) and run PhotoComparer.
You can also drag and drop images onto the dialog—whichever side you drop it on will be used to compare against the image on the opposite side.

Note 1: Shoutout to everyone who’s shared their image comparison algorithms—especially the one from here, which was the main barebones inspiration for my pHash implementation.

Note 2: Because of the way resizing and grayscale conversion is handled, results will definitely differ from more advanced tools. Just keep in mind this is a proof of concept made by an Opus enthusiast.

Note 3: The script can’t recognize rotated images as similar. From what I read, it looks like none of the three main algorithms can handle that either. Also, it only works with image formats supported by Windows' WIA implementation—as far as I know, that includes PNG, BMP, JPG, and GIF.

Note 4: This script is a test project. I’m sharing it here to exchange ideas, get suggestions, and hear your feedback. If it turns out to be useful, it could definitely be expanded to compare batches of images and, for example, export the results to an Opus duplicate collection. And hey, maybe we can even save a few bucks by not buying yet another piece of software—and just add one more handy tool to the Opus toolbox! :grinning_face:

9 Likes

Very interesting! I’ll try it out on some time-lapse and wildlife surveillance image sets. I always thought the math would be a bit too complex for JScript, but apparently, it’s doable! :+1:

interesting.
I use this
Awesome Duplicate Photo Finder - Find and Remove Duplicate or Similar Images

Awesome Duplicate Photo finder does not look at EXIF date metadata.
There are only 2 de-duping applications that can be used to compare photos' EXIF DateTimeOriginal: Duplicate Cleaner Pro 5 (by DigitalVolcano) and dupeGuru.

In my experience organizing clients' digital photo and video collections, I have found that the collections typically include between 5% and 20% photos with no EXIF DateTimeOriginal.

I appreciate your efforts on this very much.
While one could 'save a few bucks' by improving the DOpus de-duping capability, I estimate it would take you years to match the capabilities of good existing de-duping applications.
I am an expert at photo duplicate removal and work with the developers of Duplicate Cleaner Pro (by DigitalVolcano).
Identifying duplicates is only one step. Having options to help you choose duplicates to remove (even Exact duplicates) based on things like folder name, folder path length, filename, and added metadata (like Keywords) is very important.
I just started de-duping a clients' collection of 395,000 photos and videos.
If you have any specific questions, feel free to ask.

A heads‑up on this: I think I’ve figured out how to add support for rotated/flipped images—and the best part is it doesn’t need any extra image manipulation!

2 Likes

Thanks for your feedback.

First, just to clarify: I’m not building a "de‑duper", but a tool focused on image identification and analysis—not necessarily for "de-duping" or deletion only.

Second, based on DOpus’s scripting architecture and my limited experience, implementing duplicate detection and filtering won't take "years", but probably a few weeks of well‑planned work, especially since I'm juggling this with my day job.

Third, this tool isn’t actually meant for "expert" or "professional" use in photo duplicate removal (whatever that means). It’s more of a proof of concept on DOpus scripting capabilities, aimed at more enthusiastic users.

1 Like

and it is awesome, many thanks - is there a problem with small images ? I do a lot of icon images, but it comes with warning/error that image is too small.

Yes, because the first thing the algorithm does is shrink the image down to 32x32. Any image smaller than that would need to be upscaled, which could potentially affect the rest of the processing. That would increase the chance of false positives—basically making it think most small images are similar in some degree.

I didn’t mention this earlier, but transparency in images also plays a role in increasing inaccurate results.

FWIW, last night I played around with the other algorithms, and I remember that dhash can handle images as long as they’re bigger than 9x8. So I could probably add some auto‑detection to switch the algorithm based on image size.