Compare Images in VBA

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
JasonT
Posts: 4
Joined: 2012-10-01T05:00:50-07:00
Authentication code: 67789

Compare Images in VBA

Post by JasonT »

Hi

I want to compare 2 images and display the difference in VBA.

How do i write the code?

Thank you.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Compare Images in VBA

Post by magick »

Use ImageMagickObject. It includes a Compare() method to compare two images.
JasonT
Posts: 4
Joined: 2012-10-01T05:00:50-07:00
Authentication code: 67789

Re: Compare Images in VBA

Post by JasonT »

I tried to input the command line " $ compare -compose src StudPath RefPath difference.png" but received a syntax error.

I am trying to compare 2 images and the difference is saved as another image. Is this possible?

I tried another way of writing, (RefPath/StudPath is the path of my image)

Dim VarName As New MagickImage
Dim compare As Image

VarName.compare , RefPath, StudPath, compare.jpg


but received an error which says" Object variable not set"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Compare Images in VBA

Post by fmw42 »

try just

compare -metric rmse image1 image2 null:

if the two images are the same size.
JasonT
Posts: 4
Joined: 2012-10-01T05:00:50-07:00
Authentication code: 67789

Re: Compare Images in VBA

Post by JasonT »

fmw42 wrote:try just

compare -metric rmse image1 image2 null:

if the two images are the same size.
rmse is highlighted and an error shows up which reads "Complie Error, Expected: End of Statement"
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Compare Images in VBA

Post by fmw42 »

try

compare -metric rmse rose: rose: null:

change the rmse to any other metric. If these fail, then you have a problem with your IM install or you have some other compare function on your system and need to rename the IM compare.

see
http://www.imagemagick.org/Usage/compare/#statistics
JasonT
Posts: 4
Joined: 2012-10-01T05:00:50-07:00
Authentication code: 67789

Re: Compare Images in VBA

Post by JasonT »

Failed again.

I am writing in VBA, do i have to change the way in writing the command line? (declare IM etc.)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Compare Images in VBA

Post by fmw42 »

You may have to provide the full path to compare when using any scripting system such as VBA, Applescript, PHP exec(), etc
Post Reply