GNOME Bugzilla – Bug 321431
ImageMagick newer than 6.2.3 breaks TCImage.compare()
Last modified: 2005-11-22 21:07:26 UTC
Noticed couple of things in the image comparison function. 1. Case when 'metrics' is specified in the image compare: The comparison function always returns the result as fail even if the image files are same. This is because for the 'metric didn't fire' case, the check made is that the length of the output of 'compare' should not be 1. But this condition satisfies even when the images are same (since length of the output of 'compare' will be 3). I noticed that for error conditions, the length of the output of 'compare' is '1'. Attaching a patch with this change. 2. Case when no metrics is specified in the image compare: Here too, the comparison function returns the result as 'fail' even for image files that are same. This is because, the 'compare' command does not return an empty list when the images are same.
Created attachment 54728 [details] [review] Proposed patch
Created attachment 54798 [details] Log of my shell trying to reproduce
I couldn't reproduce this. How exactly are you invoking TCImage.compare(), what is output to the log, and what version of ImageMagick are you running?
1. In my script, the image compare was invoked as: label = "Image compare" image1 = "/home/mukta/image1.png" image2 = "/home/mukta/reimage1.png" TestImage.compare(label, image1, image1, metric='PSNR') TestImage.compare(label, image1, image2, metric='PSNR') TestImage.compare(label, image1, image1, metric='MSE') TestImage.compare(label, image1, image2, metric='MSE') The output in the log file was: 2005.11.18 20:43:10 Image compare: Failed - inf dB 2005.11.18 20:43:10 Image compare: Failed - 32.2696 dB 2005.11.18 20:43:10 Image compare: Failed - 0 dB 2005.11.18 20:43:10 Image compare: Failed - 2.54674e+06 dB 2. The version of ImageMagic is 6.2.5. $compare -version Version: ImageMagick 6.2.5 10/18/05 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2005 ImageMagick Studio LLC 3. Also, when I run the compare command on the commandline, it gives me an output whose length is 3 and hence TCImage.compare() returns the result as 'failed'. $compare -metric "PSNR" ./image1.png ./reimage1.png z.png $32.2696 dB $48,48,PNG $
Oh boy. It looks like from ImageMagick 6.2.4 onwards, we need something like your patch. Before that version, however, we need what's in HEAD now. I guess this means we need to check the ImageMagick version, and use "is" instead of "is not" if it's 2.6.4 or newer. I'll try hacking up a new patch.
clarifying title
Created attachment 55110 [details] [review] revised patch OK, here's my patch that fixes the issue for newer versions of ImageMagick, but keeps it working the same for older versions. It does this by parsing the output of 'compare -version' to get the version string.
Moving to ASSIGNED
Just committed the fix.