compare -metric PSNR, return code always 1
Posted: 2016-07-28T15:23:33-07:00
With 6.8.6-10 (I think) 'compare' now provides a return code. From the man page:
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.
Steps to reproduce (works with any jpg, png, svg, etc)
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.
Code: Select all
The compare program returns 2 on error otherwise 0 if the images are similar or 1 if they are dissimilar.
Code: Select all
compare -metric PSNR image1 image2 image_diff_output
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 $?
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.