Page 1 of 1

compare -metric PSNR, return code always 1

Posted: 2016-07-28T15:23:33-07:00
by notpeter
With 6.8.6-10 (I think) 'compare' now provides a return code. From the man page:

Code: Select all

The compare program returns 2 on error otherwise 0 if the images are similar or 1 if they are dissimilar.
Running with '-metric PSNR', even if images are identical (same file) 'inf' is correctly printed to stderr but the the return code is always 1.

Code: Select all

compare -metric PSNR image1 image2 image_diff_output
Steps to reproduce (works with any jpg, png, svg, etc)

Code: Select all

wget http://git.imagemagick.org/uploads/project/avatar/8/logo.jpg
compare -metric PSNR logo.jpg logo.jpg logo_diff.png
echo $?
Image

I ran into this when upgrading from Ubuntu 14.04 (ImageMagick 6.7.7-10) to Ubuntu 16.06 (ImageMagick 6.8.9-9) and verified it's still an issue in ImageMagick 6.9.4-9 and I assume ImageMagick 7 as well.

Re: compare -metric PSNR, return code always 1

Posted: 2016-07-29T17:12:54-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @ https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @ http://www.imagemagick.org/download/beta/ by sometime tomorrow.