Check if images are the same

I load Quicklook pictures for files on the Mac. For some extensions there is no Quicklook picture (for instance .p7s). However, Quicklook still gives me a picture of an empty document back. Which overwrite the icon I get for the extension. So I want to compare the Quicklook picture to an empty document icon.

Is there a better way to compare picture than comparing single pixels with an RGBSurface? How do I avoid hardcoding the empty document icon?

You might consider using a hash. Use something like Picture.GetData with a PNG with Quality set to 100 and then do a SHA1 hash on it.

A hash is a good idea. I’ll try that first.

[quote=411608:@Beatrix Willius]I load Quicklook pictures for files on the Mac. For some extensions there is no Quicklook picture (for instance .p7s). However, Quicklook still gives me a picture of an empty document back. Which overwrite the icon I get for the extension. So I want to compare the Quicklook picture to an empty document icon.

Is there a better way to compare picture than comparing single pixels with an RGBSurface? How do I avoid hardcoding the empty document icon?[/quote]

This may be overkill, but for all image comparisons I tend to use perceptual hashes:

https://forum.xojo.com/conversation/post/66790 (here I comment in 2014 about how I commented about it earlier, but the thread in general has good responses).

P-Hashes are usually pretty quick (they can usually use built-in resizing functions) and pretty accurate.

http://hackerfactor.com/blog/index.php%3F/archives/432-Looks-Like-It.html
https://www.phash.org

P-hashes as better for finding out if an image is similar to another even if it has suffered minor alterations. It may not be the best approach for straight up comparing a picture with an existing one.