Cheat #2: Use Custom Commands to Bypass the Shell
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
harness very elementary custom commands
. A file containing such elementary customs look something like:
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 : |
|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: 07-September-2021 11:05 UTC Commit: c85a4f425469
G'MIC is an open-source software distributed under the
CeCILL free software licenses (LGPL-like and/or
Copyrights (C) Since July 2008,
David Tschumperlé - GREYC UMR CNRS 6072, Image Team.