Gmic batch processing - part II

Hello,

I just posted a second article about batch processing with gmic. It shows how to daisy chain different gmic functions, how to use functions to make the commands better readable and how to produce different versions of one photo, each with different filter parameters. Click the link below if this sounds interesting to you!

Regards, Paul.

https://paulsphotopalace.wordpress.com/2016/06/21/gmic-batch-processing-part-ii/

2 Likes

Fantastic! I’m working on a simple shell script to output several versions of the same image with different sharpening parameters. This is super helpful!

You’re welcome! You’re welcome!

Maybe some remarks:

  • The path of the G’MIC user file on Linux is $HOME/.gmic, and on Windows %APPDATA\user.gmic (the filename is not the same).
  • You could have pipe your two custom commands in a single G’MIC command instead, like :
my_command : 
  -iain_iains_nr 0.613497,9.07975,2,609.756,390.244,0,1,0,0,0,1.35,0,0  # my_nr
  -gimp_unsharp_octave 6,4,3,0,11,0,24,0

and then :

$ gmic input -my_command output

(I’m sure you know, but maybe some readers not ! :slight_smile: ).

  • If you want different versions of the same command, you could have also introduced arguments in the custom command defined in your .gmic file, like this :
my_command : 
  -iain_iains_nr 0.613497,9.07975,2,609.756,390.244,0,1,0,0,0,1.35,0,0  # my_nr
  -gimp_unsharp_octave $1,4,3,0,11,0,24,0

then

$ for i in {1..10}; do echo $i; gmic image.jpg -my_command $i -o octave.$i.jpg;done

That’s it! Excellent article by the way :clap:

Hello David,

I updated the path and file name on Windows. I’m a noob with that OS, using exclusively Linux for the last 10 years or so.

About piping the commands: yes I know, but for the moment I have some special (and very secret) reasons to write it this way! :relaxed:

On your last statement: good to know. I’m also tempted to respond in a more cryptic way:
Tim Toady or Tim Toady Bicarbonate! (Hint: feed that to a search machine). :smirk:

1 Like

Btw, I looked around in the documentation but I can’t find the function to let a user choose a file in the G’MIC plugin for Gimp, like the filter Import data in the section Various. Anyone?

Regards, Paul.

Hello @paulmatth,
You can simply use the file() parameter in your interface description, like this :

#@gimp My filter : my_filter, my_filter
#@gimp Filename = file("Default_filename")

my_filter : 
    -text_outline "$1",2,2,18 

Note that you should always have "$1" quoted to avoid issues with filenames containing spaces.

Hello @David_Tschumperle,

Thanks for your quick answer. But perhaps something is wrong, the above code snippet gives the following, no file selector field to see. I’ll have a second look later today, got some work to do.

Regards, Paul.

Ah yes sorry, I forgot the : :

#@gimp My filter : my_filter, my_filter
#@gimp : Filename = file("Default_filename")

my_filter : 
    -text_outline "$1",2,2,18

That’s it! Thank you very much for your help.

I didn’t notice the typo, as I just started to learn how to create filters (which is ridicilous easy btw!). :slight_smile:

Of course it is !
How hard this would be to maintain all these filters otherwise ? :slight_smile:

I’m new to this forum so please redirect me to another topic or forum if this is not the right place to ask.

Over the last 2 years I’ve used update1582.gmic regularly in bash sh files to filter png and jpegs,
with very few problems.

Now after updating to 179 I’m encountering issues with nearly every bash call I make to update179.gmic.

Here is an example.

#!/bin/bash
gmic IN.JPG update179.gmic -gimp_adjust_colors -100,100,-3.82716,0,19.7531,0 -o OUT.JPG

This command returns the following error.
*** Error in ./gimp_adjust_colors/adjust_colors/*repeat#4214/*local#4214/ (file ‘update179.gmic’, line #4215) *** Item substitution ‘{0==255 && 0==0?[im,iM]:[min(0,255),max(0,255)]}’: Invalid item ‘[im,iM]’ in expression ‘…&& 0==0?[im,iM]:[min(0,255),max(0,255)]…’.

Now if I go back to the GIMP interface I can clearly see that the parameters in the successfully generated output verbose layer as
[G’MIC] Basic adjustments: -gimp_adjust_colors -100,100,-3.82716,0,19.7531,0

This is not only isolated to gimp_adjust_colors but has also occured with emboss, gradient, and other gmic filters in 179.

Any suggestions appreciated.

Thanks

Hi,
I have the impression that you use the file update179.gmic without having updated gmic! If you type gmic -version there should come release 1.7.9 !

1 Like

Thanks that seemed to be the problem.

I used the instructions found at this link to install 1.7.9 on Ubuntu 16.10.

http://linuxg.net/install-gmic-on-ubuntu/

The next problem I have is that the update gmic file is not seen. This forces me always to copy
the gmic file into the directory where I’m executing the gmic command or gmic batch command.

For now my update179.gmic file is in /home/darrell/.config/gmic/.

Is it necessary to always have to move the update*.gmic to the folder where the command line
gmic is being triggered or is there someway to place it on the path?

Please advise

If you installed a packaged version of gmic, it should be in your path, but it sounds like it isn’t.

I’ve added ~/bin to my path, so any program I need goes in there.

The update file should be put only in a single folder, namely $HOME/.config/gmic/ (on Linux), or %APPDATA%/gmic on Windows. All G’MIC interfaces (cli, plug-in, …) should be then able to detect and use it.