Cheat #2: Use Custom Commands to Bypass the Shell
TL;DR: Except for
impromptu experiments, put cheats and tutorials in command files. Use a
.gmic extension, then cite the command file in a short, simple pipeline.
Most processing takes place in the command files.
gmic shellbypass.gmic …
This technique shields commands written in
shellbypass.gmic from an initial pass by the shell's command line interpreter. That interpreter is not the same as G'MIC's and shell misbehavior arises because characters like
(,
),
%,
$ are typically significant to both interpreters.
For this reason, the
cheatsheets and
tutorials harness very elementary
custom commands. A file containing such elementary customs look something like:
<custom_command_name_1> :
<gmic command>
<gmic command>
<gmic command>…
<custom_command_name_2> :
<gmic command>
<gmic command>
<gmic command>…
.
.
.
<custom_command_name_n> :
<gmic command>
<gmic command>
<gmic command>…
These may be regarded as so many aliases, where
custom_command_name_n stands in for the series of commands that follow it. Such a substitution technique is a very limited application of the more comprehensive technique
Adding Custom Commands, and the related exercise
3D Bouncing Balls. By aliasing our exploratory pipelines to custom commands in a command file, then including that file, sets up a separate processing stream which bypasses shell processing.
G'MIC — and
only G'MIC — processes these definitions, this in the context of adding new custom commands to the environment. The operating shell is not entirely divorced from the process, one still has to invoke
gmic, extend it with a file of custom commands, then invoke the command aliasing the exploratory pipeline, but this effort almost entirely avoids typing characters to which both interpreters are sensitive. Here is an illustration:
diffblur :
+blur. 3
-sub
-round 1 | Create a text file, diffblur.gmic to hold the custom command diffblur. The first line names the command. One space and then a colon : character. The G'MIC implementation follows on the second and subsequent lines. |
| If possible, minimize specifics like file names or fixed-value arguments. Think reuse! |
Now invoke the custom command, adding specifics like what is being input and where the output goes.
$ gmic diffblur.gmic -input e_letter.png -diffblur -normalize 0,255 -output e_ltr_diffblur.png.
Updated: March 7 2023 12:15 UTC Commit 220bd6b91cf3556158551b6ca6d8f6e242b72850
G'MIC is an open-source software distributed under the
CeCILL free software licenses (LGPL-like and/or
GPL-compatible).
Copyrights (C) Since July 2008,
David Tschumperlé - GREYC UMR CNRS 6072, Image Team.