Page 1 of 1

How to write compare.exe return value to file?

Posted: 2008-05-21T07:57:34-07:00
by bmrowe
I have found out how to log to a file instead of the console window, but is there a way to get the return value sent to a file as well?

IE: if I run compare.exe -metric AE image1.jpg image2.jpg out.jpg , I want the return value to be sent somewhere other than the console.

I need this because I am running this command from a website on iis which means no one can see the command line to get this output.

Thanks for the help.

Re: How to write compare.exe return value to file?

Posted: 2008-05-21T12:20:54-07:00
by fmw42
try for example

convert rose: rose.jpg
compare -metric rmse rose: rose.jpg null: 2> tmp.txt

Re: How to write compare.exe return value to file?

Posted: 2008-05-21T19:15:21-07:00
by bmrowe
This would not work in my situation because I am starting the program as a process in a .NET monorail app that has some certain privilege requirements and i can't get at the command line to use the '>' operator. But yes, in the typical .NET app you could do:

cmd /c compare.exe image1.jpg image2.jpg out.jpg >> result.txt 2>&1

I did manage to find a solution that worked through a combination of things. The main issue I was running into was that compare writes all output to stderr instead of stdout. Whoever made this decision should definitely rethink the functionality of writing expected output to stderr. I edited the source to write to stdout and rebuilt compare.exe. Using this app I was about to accomplish what was needed.


If anybody knows why compare is writing to stderr feel free to enlighten me. Otherwise I think this code should be changed in future releases.

Re: How to write compare.exe return value to file?

Posted: 2008-05-21T20:04:23-07:00
by fmw42
I cannot answer why IM does this, but other things I have had to write to file all seem to follow the same pattern, e.g.

convert rose: -type Grayscale -fx "u==rgb(255,255,255)?debug(u):1; u" null: 2> list.txt

to find all pixel locations with graylevel 255