Command Items and Selections
A G'MIC item that is not a filename nor a special input string designates a command most of the time. Generally, commands perform image processing operations on one or several available images of the list.
Reccurent commands have two equivalent names (regular and short). For instance, command names resize and r refer to the same image resizing action.
A G'MIC command may have mandatory or optional arguments. Command arguments must be specified in the next item on the command line. Commas , are used to separate multiple arguments of a single command, when required.
The execution of a G'MIC command may be restricted only to a subset of the image list, by appending [selection] to the command name. Examples of valid syntaxes for selection are:
command[-2]: Apply command only on the penultimate image [-2] of the list.
command[0,1,3]: Apply command only on images ,  and .
command[3-6]: Apply command only on images  to  (i.e, , ,  and ).
command[50%-100%]: Apply command only on the second half of the image list.
command[0,-4--1]: Apply command only on the first image and the last four images.
command[0-9:3]: Apply command only on images  to , with a step of 3 (i.e. on images , ,  and ).
command[0-9:25%]: Apply command only on images  to , with a step of 25% (i.e. on images , ,  and ).
command[0--1:2]: Apply command only on images of the list with even indices.
command[0,2-4,50%--1]: Apply command on images , , ,  and on the second half of the image list.
command[^0,1]: Apply command on all images except the first two.
command[name1,name2]: Apply command on named images name1 and name2.
Indices in selections are always sorted in increasing order, and duplicate indices are discarded. For instance, selections [3-1,1-3] and [1,1,1,3,2] are both equivalent to [1-3]. If you want to repeat a single command multiple times on an image, use a repeat..done loop instead. Inverting the order of images for a command is achieved by explicitly inverting the order of the images in the list, with command reverse[selection].
Command selections [-1], [-2] and [-3] are so often used they have their own shortcuts, respectively ., .. and .... For instance, command blur.. is equivalent to blur[-2]. These shortcuts work also when specifying command arguments.
G'MIC commands invoked without [selection]
are applied on all images of the list, i.e. the default selection is [0--1]
(except for command input
whose default selection is [-1]'
Prepending a single hyphen - to a G'MIC command is allowed. This may be useful to recognize command items more easily in a one-liner pipeline (typically invoked from a shell).
A G'MIC command prepended with a plus sign + does not act in-place but inserts its result as one or several new images at the end of the image list.
There are two different types of commands that can be run by the G'MIC interpreter:
Built-in commands are the hard-coded functionalities in the interpreter core. They are thus compiled as binary code and run fast, most of the time. Omitting an argument when invoking a built-in command is not permitted, except if all following arguments are also omitted. For instance, invoking 'plasma 10,,5' is invalid but 'plasma 10' is correct.
Custom commands, are defined as G'MIC pipelines of built-in or other custom commands. They are parsed by the G'MIC interpreter, and thus run a bit slower than built-in commands. Omitting arguments when invoking a custom command is permitted. For instance, expressions flower ,,,100,,2 or flower , are correct.
Most of the existing commands in G'MIC are actually defined as custom commands.
A user can easily add its own custom commands to the G'MIC interpreter (see section Adding Custom Commands
for more details). New built-in commands cannot be added (unless you modify the G'MIC interpreter source code and recompile it).