Page 1 of 1

Option -metric outputs to STDERR

Posted: 2007-07-24T05:45:12-07:00
by sven
Hi magick,

the documentation says (http://www.imagemagick.org/script/comma ... php#metric) that the option -metric AE outputs to STDERR. I wonder, why it does not output to STDOUT. Well, of course it's the error count of the number of different pixels, but it makes it difficult to only read the number of different pixel and not other error information.

Is there any way to change the output to STDOUT (only for this option) or to output the information in a structered way in order to ignore other error outputs?

Kind regards,
Sven

Re: Option -metric outputs to STDERR

Posted: 2007-07-24T06:43:31-07:00
by magick
We send the metric to stderr because the user may want to send the difference image to stdout. Something like this:
  • compare -metric pae reference.png image.png png:- | identify -verbose -

Re: Option -metric outputs to STDERR

Posted: 2007-10-31T15:39:38-07:00
by magick
There is at least 10 different places in ImageMagick that writes text info to stderr and any image to stdout. Its been this way for quite sometime (other than the occasional bug) and we intend on keeping it that way. If we change it now it would most likely break a lot of existing scripts and bring ire from numerous users.

Re: Option -metric outputs to STDERR

Posted: 2007-11-15T22:01:41-07:00
by anthony
Typically what you would do is junk the image output and then redirect stderr to either stdout or a file using your command line shell.

For example

Code: Select all

   convert -metric AE image1 image2 null: 2>metric.txt
or

Code: Select all

     result=`convert -metric AE image1 image2 null: 2>&1`
The 2> and 2>&1 are NOT Imagemagick syntax, but Bourne or BASH shell syntax, if you are on a UNIX-like environment.

see the still rough notes in IM Examples Compare
http://imagemagick.org/Usage/compare/#compare