AWS S3 Image Comparison with PHP or JavaScript
New here? Learn about Bountify and follow @bountify to get notified of new bounties! x

Up until now I've been using phasher class from PHP to compare images to one another, but recently I decided to host my files on Amazon's S3, and I just can't get that functionality to work for me anymore. I know that I could download the images down and compare them again using the phasher, but that would be too slow - I'm hoping to have to process streamlined.

Here's the scenario: John Smith has two images - same photo, but one is at lower quality:

I'd like to be able to return a comparison match somehow, either with PHP or Javascript. Again, the images are not stored locally. Any suggestions would be highly appreciated. If it works and streamlines well I'll throw in a tip.

So imagine a list of 3 different images, I want to compare each image to another and return comparison index. I.e.:
image 1 to image 2 (40% match),
image 1 to image 3 (2% match),
image 2 to image 3 (3% match)

This way I could identify that image 1 and image 2 are similar.

awarded to dekkard

Crowdsource coding tasks.

1 Solution

Winning solution

It's not quite clear from your description, but if you need a visual comparison, you can check out my solution here:

One thing to note is for the canvas comparison to work you might need to configure your S3 to allow CORS.
Here are a couple of hints:

Let me know if you have any problems with that.

Thanks dekkard for a prompt reply. I updated my question to reflect what I'm looking for. I'll look into the CORS stuff today to see if I can find something that works with that - if I find a solution, I'll post it below.
tolousn over 5 years ago
This thing actually shows you the difference percentage. Here's what it looks like: BTW, to test your images you can also try a cors proxy, like
dekkard over 5 years ago
thanks dekkard - I was using resemble before but couldn't get it to work, but I think it would be my best game plan. I tried updating my CORS, but it doesn't seem to take effect - it's quite annoying, I must have tried 50 different configurations, I think I'm still missing something. I'll keep poking around, as soon as I find something I'll post back.
tolousn over 5 years ago
Do you still experience any problems with your setup (or anything else)? Just checked once again and it seems you got it right - your bucket returnes proper CORS headers and Resemble shows the images.
dekkard over 5 years ago
Yeah, after long hours, I've realized that I need to set up a cloudfront with proper permissions and to pass the headers properly then use the cloudfront url instead of the bucket url. Geez, that was a pain. This will definitely get me on the right path. Thanks for helping out dekkard.
tolousn over 5 years ago