How to write compare.exe return value to file?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
bmrowe

How to write compare.exe return value to file?

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

try for example

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

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

Post 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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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
Post Reply