0

i have a problem with compare command.

I use this to output result to screen, but I receive nothing ( echo is empty ) but after executing command I obtain a numeric value

COMP=`compare -metric PSNR 00000003.jpg 00000004.jpg difference.png`<br>
echo "$COMP"


I tried this:

OUTPUT="$(compare -metric PSNR 00000003.jpg 00000004.jpg difference.png)"
echo "${OUTPUT}"

But it doesn't help

codeNinja7
  • 112
  • 7

1 Answers1

1

compare writes on stderr not stdout, so use the following to divert stderr to stdout:

comp=$(compare -metric PSNR 1.png 2.png diff.png 2>&1)
echo $comp
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432