compare exits with a non-zero exit code when no error

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
Hubbitus
Posts: 66
Joined: 2010-05-04T10:50:21-07:00
Authentication code: 8675308
Location: Russia, Saint-Petersburg

compare exits with a non-zero exit code when no error

Post by Hubbitus »

Please see report from one of our Fedora users: https://bugzilla.redhat.com/show_bug.cgi?id=981944
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: compare exits with a non-zero exit code when no error

Post by fmw42 »

It works fine if you specify a metric in IM 6.8.6.4 Q16 Mac OSX

compare rose: rose: null:
returns nothing

compare -metric rmse rose: rose: null:
0 (0)

I do not know if there is supposed to be a default metric or not. I always specify one (mostly rmse).
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: compare exits with a non-zero exit code when no error

Post by magick »

Have the user add -metric RMSE to the command line until we can get a patch for the default metric, normalized cross correlation distortion. If two images are identical, -metric RMSE returns 0 as expected.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: compare exits with a non-zero exit code when no error

Post by fmw42 »

A perfect match for -metric ncc is 1 and not zero. If the user wants that default, then just add -metric ncc until the issue is resolved

see http://www.imagemagick.org/Usage/compare/#statistics
Hubbitus
Posts: 66
Joined: 2010-05-04T10:50:21-07:00
Authentication code: 8675308
Location: Russia, Saint-Petersburg

Re: compare exits with a non-zero exit code when no error

Post by Hubbitus »

Thank you.
I have repost you answer as workaround and wait fix in one of update.
TomH
Posts: 1
Joined: 2013-07-15T13:11:08-07:00
Authentication code: 6789

Re: compare exits with a non-zero exit code when no error

Post by TomH »

Hi. I'm the original reporter of this issue, and the test case I gave in my bug was actually a simplified version of the real code. The actual inspiration for the report was this code:

https://github.com/mapbox/tilelive-mapn ... ert.js#L22

which is part of the test suite for some software I was packaging.

It runs the compare tool (with a metric switch) to compare two images, and then first checks the exit code (to see if the tool worked) and then if that is zero is looks at the metric that was output to see if the two images matched.

The metric in use was PSNR and in the case I was dealing with the result was "inf" which is treated as a match, except that the new exit code of 1 was being treated as a failure. If the change in exit code is expected then that's fine, but I'll need to pass that information on to the authors of the test suite.
Post Reply