compare and different sizes

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
dav1988
Posts: 9
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

compare and different sizes

Post by dav1988 » 2018-01-07T13:27:04-07:00

Hi. I am not very expert. I only use imagemagick's "compare" in order to check quality of images that i upload on hosting images websites.
I have changed my pc so downloaded a new version of imagemagick. Yesterday i downloaded : imagemagick 6.9.9.33 portable Q16 x64.zip.
My question is: my previous imagemagick ( i dont remember the release) did not compare images of different sizes. While this one does compare images of very different sizes as well , for ex 600x576 and 600x584.

Do you think i made an error installing this release of imagemagick or it is normal?
Thanks in advance.

User avatar
fmw42
Posts: 22422
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: compare and different sizes

Post by fmw42 » 2018-01-07T13:42:30-07:00

Imagemagick has always allowed the comparison of equal or different sizes. There is a difference in syntax.

To compare images of the same size, use

Code: Select all

compare -metric rmse image1 image2 diffimage
To compare different size images, use

Code: Select all

compare -metric rmse -subimage-search largeimage smallimage diffimage
The result will be diffimage-0 and diffimage-1 or two layers depending upon the output format. You can use null: in place of diffimage, if you just want the score.

See
http://www.imagemagick.org/script/compare.php
http://www.imagemagick.org/Usage/compare/

dav1988
Posts: 9
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: compare and different sizes

Post by dav1988 » 2018-01-07T13:49:53-07:00

i always used this syntax:

compare image1.jpg image2.jpg diffimage.jpg

is it wrong?

the problem is that i am sure that i could not compare images of different sizes using this syntax. But not this syntax seems to work with different sizes as well.

Thanks again

User avatar
fmw42
Posts: 22422
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: compare and different sizes

Post by fmw42 » 2018-01-07T14:11:57-07:00

Your syntax will work for equal sizes. It uses the default -metric. But it should not work for two different size images without adding -subimage-search. So that looks to me like a bug

dav1988
Posts: 9
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: compare and different sizes

Post by dav1988 » 2018-01-07T14:27:22-07:00

This was my problem. Now this syntax works for different sizes as well. For example if i write:
compare imagesize1.jpg imagesize.jpg diffimage.jpg

the result is the firt image (imagesize1.jpg) all red.

Do you think there was some error installing this imagemagick and i should delete and install it again?

User avatar
fmw42
Posts: 22422
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: compare and different sizes

Post by fmw42 » 2018-01-07T14:53:44-07:00

No, I do not think there is an install error. I would not recommend comparing two images of different sizes unless you add -subimage-search. Otherwise, I do not know what part of the larger image is being compared with the smaller image. You will not be getting the best match unless you properly use -subimage-search in the compare command.

All red means a total mismatch.

User avatar
fmw42
Posts: 22422
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: compare and different sizes

Post by fmw42 » 2018-01-07T15:05:16-07:00

Try this:

Logo:
Image

Wizard subsection of logo:
Image

Code: Select all

time compare -metric RMSE -subimage-search logo.png logo_wizard.png logo_wizard_similarity.png
0 (0) @ 327,130
real 0m23.520s
user 1m29.363s
sys 0m0.840s

Note: time is a unix command to measure the run time (23.5 sec)

Diff (perfect match, since no red):
Image

Similarity (showing best match point):
Image

dav1988
Posts: 9
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: compare and different sizes

Post by dav1988 » 2018-01-07T15:22:23-07:00

ok thanks

any way i downloaded from here:

http://www.imagemagick.org/download/binaries/

imagemagick-7.0.0-21-portable-q16-x86.zip

downloaded on my desktop, and then i extract files in the same folder where i will put images to be compared.

Is it a correct proedure to install imagemagick?

User avatar
fmw42
Posts: 22422
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: compare and different sizes

Post by fmw42 » 2018-01-07T15:45:10-07:00

Yes, it seems reasonable, thought I am not an expert on Windows.

dav1988
Posts: 9
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: compare and different sizes

Post by dav1988 » 2018-01-07T15:59:44-07:00

ok thanks. just a last question about images sizes.

if i upload on a hosting images website a photo, and the uploaded image has the same width and the same height of the original image (for ex 600x576) , can i be sure that the image has not been deformed by the site (enlarged or elongated) and the ratio height/basis is unchanged?

thanks

User avatar
fmw42
Posts: 22422
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: compare and different sizes

Post by fmw42 » 2018-01-07T18:29:17-07:00

Using hosting sites is problematic. Some do change the image, though usually not the width or height, but change the format say from tif to jpg. A number of cheap hosting sites convert images to jpg or rename them.

User avatar
fmw42
Posts: 22422
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: compare and different sizes

Post by fmw42 » 2018-01-07T18:30:05-07:00

See comments to my bug report at viewtopic.php?f=3&t=33329

dav1988
Posts: 9
Joined: 2018-01-07T13:18:56-07:00
Authentication code: 1152

Re: compare and different sizes

Post by dav1988 » 2018-01-07T19:33:47-07:00

thanks!! :)

Post Reply