Page 2 of 2
Re: compare's exit code is always 0
Posted: 2013-09-11T12:41:10-07:00
by benze
magick wrote: We'll keep the exiting exit status for all ImageMagick utilities except the compare utility. For it, we will return the same exit status as grep. That is if the images are similar and no errors, return 0. If the images are dissimilar and no errors, return 1. If an error occurs, return 1.
I don't understand. Part of the idea of the exit code is to be able to determine if there was an error or not. But here the suggestion is to make the utility return the same error code in the case of a success and an error. In both cases, whether the images are different or an error was thrown, return 1. But that does not tell the user or the calling utility if an error was thrown or if the two images are just different. Consequently, there is no way to know if the result can be "trusted". ie: did the utility complete properly and the images are indeed different, or was there an error in the process and the utility crashed (ex: file does not exist, file access errors, etc). Consequently, a non-zero exit code ends up not meaning anything at all.
At the very least, I would expect a different exit code on error vs on difference of images (ex: 0 if images are the same, 1 if images are different, and something >1 on error depending on the error).
Re: compare's exit code is always 0
Posted: 2013-09-11T13:00:17-07:00
by fmw42
I think the idea is to use the -dissimilarity-threshold, so that if the images are too dissimilar, compare will exit with a message and give error code 1. So if you believe that some similarity value (say rmse) is too high then if that value is found, it will quit with the message and error 1. If you want it to run to completion no matter what the similarity (rmse) value is, then always include -dissimilarity-threshold 1 and it will never quit unless there is some real error and not just too dissimilar.
The IM developers can correct me on this if I misunderstand.
Re: compare's exit code is always 0
Posted: 2013-09-11T13:14:29-07:00
by dlemstra
I believe the 'If an error occurs, return 1' is a typo and should be ' If an error occurs, return 2'. This is what grep is doing.
Re: compare's exit code is always 0
Posted: 2013-09-11T14:20:15-07:00
by magick
We'll keep the existing exit status for all ImageMagick utilities except the compare utility. For it, we will return the same exit status as grep. That is if the images are similar and no errors, return 0. If the images are dissimilar and no errors, return 1. If an error occurs, return 2.
Are we good to go? If so, we'll get it coded over the next few days.
Re: compare's exit code is always 0
Posted: 2013-09-11T15:27:58-07:00
by fmw42
What determines if "similar"? Does it have to be perfect? Or are you going to use the -dissimilarity-threshold value as the determining factor? If so, won't it quit before finishing, if the values are too dissimilar.
Re: compare's exit code is always 0
Posted: 2014-10-24T22:26:40-07:00
by bigmontana
Please reconsider changing your convention. Capturing the return value from stderr is a pain in the arse.