Archive for September, 2010

G’mic: The command line behind the Gimp plug-in

0-Expendable introduction

The G’mic plug-in for Gimp is based on the G’mic language. Each filter proposed in the plug-in corresponds to a G’mic command line, each setting is just a parameter of that command line. And command lines are great because :

  1. it is a way to remember settings and filter sequences,
  2. it allows to (almost) effortlessly apply on a large set of images what you just did graphically.

Anything said below supposes that you run some kind of linux, but the spirit of it apply under other OS too.

1-How to get the command lines?

To have the plug-in tells you what you do graphically in the command line language, you just have to start Gimp from a terminal and to set it to “verbose mode”.

To start from a terminal, just open a terminal and type :


To set it to “verbose mode”, once you have open the plug-in, set the “ouput messages…” menu on the left to “Verbose”.

From now on, you’ll see text appearing in the terminal each time G’mic adapt the preview to your new setting and each time you apply a filter on your image.

Image from PhotoComiX, CC-by-nc

2-What it looks like?

Two kind of lines appear in the terminal. The ones telling what command is used to create the preview (containing the /preview/ sequence) and the ones telling what command is really applied on the picture (containing the /apply/ sequence). You are probably only interested in the last kind.

For example, the line:

[gmic_gimp]./apply/ -v -99 -gimp_mix_rgb 1,0,0,1,0,0,1,0,0,0,2,0

tells that the command called was gimp_mix_rgb and all the numbers behind correspond to the settings.

3-What to do with it?

You could just be happy to know what happens and to be able to keep everything in a text file with a simple copy/paste, but you could also want to apply it in a terminal. Just go to the directory where your file (say image.jpg) is and type:

gmic image.jpg -gimp_mix_rgb 1,0,0,1,0,0,1,0,8.5,0,2,0

Your processed image will be displayed, but not saved.
To save it instead of displaying it:

gmic image.jpg -gimp_mix_rgb 1,0,0,1,0,0,1,0,8.5,0,2,0 -o processed_image.jpg

If you have many images (whose names finish by jpg) that you want to be processed, a script like that should do it:

for i in *jpg
gmic $i -gimp_mix_rgb 1,0,0,1,0,0,1,0,8.5,0,2,0 -o processed_$i

Image Wikimedia

4-By the way

If you only want the “interested” lines to appear in your terminal, you should run Gimp with this command instead:

gimp |grep apply