Image Compare question

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Image Compare question

Post by Jerry Thomas » Mon Oct 04, 2010 11:46 pm

Our software imports from different CAD/CAM products and translates into our format.

We are trying to automate a tool to compare 'problem' files against new releases to catch anything we broke in the new translation.

These are line drawings (so not a lot of pixels per screen). When I use CompareBitmaps, I get 99% match even when they are very different. I tried the HashLib but it doesn't seem to be working.

All of these show message of r2 regardless of the image that is used.

Code: Select all

//Put Hashlib.dll in script directory
Let>HashLib=%SCRIPT_DIR%\HashLib.dll

//Get SHA1 hash of a file
LibFunc>Hashlib,FileSHA1,r,c:\Image1.BMP,buf
Mid>r2,1,r,hash
MessageModal>Hash: %hash%

LibFunc>Hashlib,FileSHA1,r,C:\Image2.BMP,buf
Mid>r2,1,r,hash
MessageModal>Hash: %hash%

//Get MD5 hash of a file
LibFunc>Hashlib,FileMD5,r,c:\Image1.BMP,buf
Mid>r2,1,r,hash
MessageModal>Hash: %hash%

LibFunc>Hashlib,FileMD5,r,c:\Image2.BMP,buf
Mid>r2,1,r,hash
MessageModal>Hash: %hash%
Any ideas on what I doing wrong?

Is there a better alternative?

Macro Scheduler V12.0.8
Windows 7 (x64)
Thanks,
Jerry

[email protected]

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Tue Oct 05, 2010 12:45 am

Try this. Looks like there is a typo in the readme file.
Should actually be r_2 instead of r2.

Make sure you put the dll in the actual path defined by HashLib variable. Use debugger to see the value of this variable as you use F8 to step through the code. In my case with version 12.0.8 I had to place the dll file in
"C:\Documents and Settings\Computer User\My Documents\Macro Scheduler 12"

Code: Select all

//Put Hashlib.dll in script directory
Let>HashLib=%SCRIPT_DIR%\HashLib.dll

//Get SHA1 hash of a file
LibFunc>Hashlib,FileSHA1,r,c:\Image1.BMP,buf
Mid>r_2,1,r,hash
MessageModal>Hash: %hash%

LibFunc>Hashlib,FileSHA1,r,C:\Image2.BMP,buf
Mid>r_2,1,r,hash
MessageModal>Hash: %hash%

//Get MD5 hash of a file
LibFunc>Hashlib,FileMD5,r,c:\Image1.BMP,buf
Mid>r_2,1,r,hash
MessageModal>Hash: %hash%

LibFunc>Hashlib,FileMD5,r,c:\Image2.BMP,buf
Mid>r_2,1,r,hash
MessageModal>Hash: %hash%

This code was tested and gave me what seemed like valid hash values for a sample bitmap file I used.

Jerry Thomas
Macro Veteran
Posts: 267
Joined: Mon Sep 27, 2010 8:57 pm
Location: Seattle, WA

Post by Jerry Thomas » Tue Oct 05, 2010 4:18 pm

Thanks adroege,
the underscore was the problem.
Thanks,
Jerry

[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts