output to stdout shell variable - no display

(Alexandre Cunha) #1


I have tried to output the sum of pixels in a shell variable, as in

> set sum = `gmic -v -1 A.pbm B.pbm --echo_stdout[0] ‘{is}’ --echo_stdout[1] ‘{is}’`

so $sum now contains two entries each the sum of pixel values in A.pbm and B.pbm. My difficulty has been on how to stop displaying the images on the screen? What should I issue to prevent displaying them? I am sure it is something simple but I just couldn’t find out how to do it.


  • Alex

(G'MIC staff) #2

Just end your G’MIC command line with command quit (shortcut q).

(Alexandre Cunha) #3


On the same topic, how do I get echo_stdout to write out two variables separated by space? The following works when I use comma,

> gmic A.pbm “a={is}” -input B.pbm “b={is}” -echo_stdout ‘$a,$b’ -quit

When I use space instead of comma I get ‘$a $b’ as output, not the values of $a and $b.

(G'MIC staff) #4

That’s because when there is an argument with a space provided on the command line, it is automatically double-quoted by G’MIC, so that when it is a filename, it can be loaded as expected without having the filename split into several G’MIC items.
And then, as G’MIC variables are not substituted inside double-quotes, it explains the behavior you get.

In your case, I would suggest something shorter, like:

$ gmic A.pbm B.pbm echo_stdout {is#0}\" \"{is#1} q

(I’ve only double-quoted the space between the two values you want to output on stdout).

(Alexandre Cunha) #5

Many thanks! Works beautifully.