That’s a quite classical problem
You have to keep in mind that the examples in the G’MIC command documentation are written in the G’MIC scripting language. In that language, you need some special characters such as '
, {
, }
and so on…
But if you call G’MIC from a shell (e.g. bash
or sh
), these special characters are also used by the shell itself, and they are used before the call to G’MIC is done.
So, depending on the shell you use, it’s not unusual to have to quote or backslash those characters so that they can be indeed passed to the G’MIC interpreter.
In your example, with a bash shell, you’ll have to transform the example syntax a little bit, and write it as:
$ gmic sp greece add "'80*cos(80*(x/w-0.5)*(y/w-0.5)+c)'" cut 0,255
and you’ll get this:
$ gmic sp greece add "'80*cos(80*(x/w-0.5)*(y/w-0.5)+c)'" cut 0,255 o output.jpg,85
[gmic]./ Start G'MIC interpreter (v.3.3.6).
[gmic]./ Input sample image 'greece' (1 image 750x500x1x3).
[gmic]./ Add expression '80*cos(80*(x/w-0.5)*(y/w-0.5)+c)' to image [0].
[gmic]./ Cut image [0] in range [0,255].
[gmic]./ Output image [0] as jpg file 'output.jpg', with quality 85% (1 image 750x500x1x3).
[gmic]./ End G'MIC interpreter.
Yes, I’ve been forced to put the add
argument between double quotes, so that the '
, (
and )
characters are passed to the G’MIC interpreter as it. If you are using another shell, you’ll have to do something else (e.g. Powershell). That’s why we cannot put directly the bash
-modified commands in the documentation.