Available filters in qmic CLI

I was looking at the list of filters https://gmic.eu/gui_filters.txt and was wondering if some of these are only available in the plugin version but not the the command line interface. I tried, e.g.,
fx_emulate_film_instant_pro using gmic imageIn.jpg fx_emulate_film_negative_color o imageOut.jpg and all I get is

[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Input file ‘imageIn.jpg’ at position 0 (1 image 5405x3603x1x3).
[gmic]-1./ Input file ‘fx_emulate_film_negative_color’ at position 1
[gmic]-1./ *** Error *** Unknown command or filename ‘fx_emulate_film_negative_color’.

Others work, such as fx_blur_linear though I have to drop the fx_ prefix to get it going.

Thanks for your help.

This command indeed does not exist. It was there a long time ago, but now, the film emulations filters have been all gathered in a single filter Colors / Simulate Film.
With that filter, with one of the ‘negative color’ film selected (here, “Fuji Superia 200”):

$ gmic input.jpg fx_simulate_film 4,1,1,1,1,4,1,1,1,1,512,100,0,0,0,0,0,0,0,50,50 output output.jpg

The command has been obtained using the ‘Copy to Clipboard’ button from the plug-in.

Thanks a lot, @David_Tschumperle. Much appreciated. I am on a Mac and the plugin is crashing most of the time. Still, wanted to explore g’mic more as I really like it. I need to find a way to get info on the individual CLI commands in the absence of a working Mac plugin.

I see.
I think you have to consider that G’MIC on mac is still in the “prototype” stage. We don’t have a Mac here for development / testing / debugging.
And apart from @KaRo , nobody seemed to want to use G’MIC on the Mac until now :slight_smile:

Hehe, my name is nobody … And yes, I understood that this is still prototype. mic seems to work quite well and I might be able to invest some time to look at the plugin if there were a starting point from a code perspective.

I have to add that I have a M1-powered MacBook and some of the filters take ages when applied on 20 megapixel images. Nevertheless, I already had fun in the last few days.


Maybe you could try to install a Linux Virtual Machine (With UTM), it should work fine.
That’s how I used G’mic on my M1 Macbook for some time, before installing Asahi Linux, which is even better since it runs natively on M1 hardware (still in alpha/beta though but you will have a dual boot with MacOS). As a matter of fact, I’m currently installing Asahi on a second M1 Macbook…

Has gmic -help <some command> been any use for you? There is also the Command Listings in the technical reference.

If a custom command (not built-in) has been hashed on startup, then: gmic echo $${ <some custom command>} will substitute the custom command name with its pipeline definition and print out the pipeline.
For example:

 $ gmic echo '$${fx_simulate_film}'
[gmic]-0./ Start G'MIC interpreter (v.3.2.7).
category=${arg0 $1,bw,instant_consumer,instant_pro,fujixtransiii,negative_color,negative_new,negative_old,print,colorslide} presets=${-_fx_cluts_$category} index={arg(1+$1,${2-10})} thumbsize,strength,brightness,contrast,gamma,hue,saturation,normalize=${11-18} if $normalize==1" || "$normalize==3 foreach { split_opacity balance_gamma[0] , a c } fi if $index>=2 path_clut=${-path_cache} name=${arg0 $index-2,$presets} clut $name,{0$_is_preview" && "!isfile(['{/${path_clut}clut_$name.cimgz}'])?17:48} repeat $!-1 { if $strength<100 +map_clut[$>] . j[$>] .,0,0,0,0,{$strength%} rm. else map_clut[$>] . fi } rm. adjust_colors $brightness,$contrast,$gamma,$hue,$saturation,0,255 if $normalize==2" || "$normalize==3 foreach { split_opacity n[0] 0,255 a c } fi elif $index==1 adjust_colors $brightness,$contrast,$gamma,$hue,$saturation,0,255 if $normalize==2" || "$normalize==3 foreach { split_opacity n[0] 0,255 a c } fi else foreach { if max(w,h)>$thumbsize rr2d $thumbsize,$thumbsize,0,2 fi } N=$! +to "Original",1%,1%,7.5%,2,0.5 Np={narg($presets)} repeat $Np { clut_name=${arg0 $>,$presets} clut $clut_name mv. $N repeat $N { if $strength<100 [$>] +map_clut. [$N] j.. .,0,0,0,0,{$strength%} rm. else +map_clut[$>] [$N] fi adjust_colors. $brightness,$contrast,$gamma,$hue,$saturation,0,255 if $normalize==2" || "$normalize==3 l. { split_opacity n[0] 0,255 a c } fi strcapitalize $clut_name clut_name=${} to. $clut_name,1%,1%,7.5%,2,0.5 } rm[$N] progress {$>*100/($Np-1)} } k[$N--1] frame 1,1,0,0,0,255 - 128 append_tiles {s=floor(sqrt($!));w>h?[s,0]:[0,s]} + 128 fi
[gmic]-0./ End G'MIC interpreter.

You can then cut-and-paste from the shell to your favorite text editor and spelunk around.

Observe that what my gmic may hash is not what your gmic may hash — much depends on what has been placed in the places where gmic looks for custom command definitions. I am never quite sure what is available to Mac users, but this last technique can give you an immediate heads up if a given custom command under discussion is available to your particular installation. The help command is not quite as definitive: it depends on whether a specially-formatted “help comment” has been written for the command. That is not usually the case for fx_… and their ilk: these are usually undocumented adapters between a gmic_qt and gmic proper.

Hope this helps.

Welcome “nobody” in the Mac g’mic community. I am not equipped with the M1 Mac, still I think the differences on Mac might be small. As long as you don’t have lots of your own g’mic script files, you should find in ~/.config/gmic/ most files, most important updatexxx.gmic, xxx=version number . There is also the gmic cash in ~/.cash/gmic, I think mostly used by the plugin. Besides there is the user file ~/.gmic if you add your own things. In the latter there is a custom function cli_start where you can add other script files. As an example a piece from me:

cli_start : _vt100=1 

#    l[] m 1,/Users/karo/sw/gmic_bm/BAM_313.gmic onfail done
    l[] m 1,/Users/karo/sw/gmic_bm/bh.gmic onfail done
    l[] m 1,/Users/karo/sw/gmic/src/gmic_stdlib.gmic onfail done
#    l[] m 1,/Users/karo/sw/gmic-community/include/karsten_rodenacker.gmic onfail done
#    l[] m 1,/Users/karo/sw/gmic-community/include/david_tschumperle.gmic onfail done
#    l[] m 1,/Users/karo/sw/gmic_bm/ak_surface.gmic onfail done
#    l[] m 1,/Users/karo/_gmic/blather.gmic onfail done
#    l[] m 1,/Users/karo/sw/gmic_bm/in.gmic onfail done

I don’t know how far you have your own build of g’mic. At least most things of the discussion list need the latest version, hence the pre_release. And that has to be build by yourself! If you are interested, I could show you my configuration and the build shell file.

By the way the hint of @grosgood is good, still you get a some sort compressed version. To learn the script it helps to look into the gmic_stdlib.gmic which is part of the environment to build g’mic on your own machine.

1 Like

Good morning, @KaRo, @grosgood and @prawnsushi. Thanks for your comments, which are much appreciated. I am a photo enthusiast for the past 50 years (or close to) and I was looking for good LUTs for black and white conversion when I came across gmic end of last week or so. And I also enjoyed the rest. I have been playing around a lot this week and I really would like to get a gmic-qt like piece of software running on my M1 Mac - though some of the filters are really slow (is that only on an M1 or in general also on a Windows PC?). gmic seems to work, I have tried the plugin for krita and it crashes all the time. The standalone version for gmic-qt (through MacPrts) seems to work most of the time bit has some bugs, such as not scaling correctly the previews… What I think is needed is a working gmic-qt version (or any other front-end to mic). I have to see that I am a trained computer science engineer but have not been programming “Mac natively” in the last couple of years, mostly done scripting languages as PHP. But a I am happy to learn new things, so @KaRo, the configuration and build shell files would be appreciated.

Nichts leichter als das!

First clone the git repositories to any folder, I have called it ~/sw
git clone GitHub - c-koi/gmic-qt: G'MIC-Qt is a versatile front-end to the image processing framework G'MIC.
git clone GitHub - GreycLab/gmic-community: Community contributions to the G'MIC software

git clone GitHub - GreycLab/gmic: GREYC's Magic for Image Computing: A Full-Featured Open-Source Framework for Image Processing
git clone GitHub - GreycLab/CImg: The CImg Library is a small and open-source C++ toolkit for image processing

The latter have two branches master and develop, I am using develop. The shell script builds gmic gmic-qt zart gmic-gimp, gmic executable is copied to /usr/local/bin . All other apps are in the respective folders.

set -x 
export PATH=/opt/local/libexec/gnubin:/opt/local/bin:/opt/local/libexec/qt5/bin:$PATH
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/opt/local/lib/opencv4/pkgconfig
cd ~/sw
git -C CImg pull
git -C gmic-community pull
git -C zart pull
git -C gmic-qt pull
git -C gmic pull
cd gmic/src
RELEASE0=`grep "#define gmic_version" gmic.h | tail -c 5`
RELEASE1=`echo $RELEASE0 | head -c 1`
RELEASE2=`echo $RELEASE0 | head -c 2 | tail -c 1`
RELEASE3=`echo $RELEASE0 | head -c 3 | tail -c 1`
DATE=$(date "+%Y-%m-%d-%H%M")
echo "${VERSION} ${DATE}"
make clean 
make -B OPENCV_CFLAGS="\$(shell pkg-config opencv4 --cflags)" OPENCV_LIBS="\$(shell pkg-config opencv4 --libs)"  EXTRA_CFLAGS="-march=native -O3 -flto -Wno-c11-extensions -Wno-deprecated-declarations -Wno-c++17-extensions -Wno-variadic-macros -Dcimg_use_opencv \$(OPENCV_CFLAGS) -Dcimg_use_heif" EXTRA_LIBS="\$(OPENCV_LIBS) -lheif" cli 
cp gmic /usr/local/bin/
make -B gimp gmic_qt zart "SUBLIBS=-lX11" || exit 

Happy gmic building! It is an excerpt from my crowdy script, not tested…
Possibly you have to install some macport packages…

By the way, as far as I know, gmic h delivers “only” the help for functions from gmic_stdlib.gmic. I am preparing me an gmic help text file with some more:

$> /usr/local/bin/gmic _vt100=0 v - it ~/.config/gmic/update\${_version}.gmic it ~/sw/gmic_bm/BAM_310.gmic it ~/sw/gmic_bm/in.gmic it ~/sw/gmic_bm/bh.gmic a y parse_cli ascii > ~/Desktop/gmic.txt

That seem to work for me in case of user.gmic.

Nice post @KaRo. Helpful even to non-Mac folk.
Small quibble. help works for every successfully hashed command, so long as it is preceded by a specially formatted “help” comment, with no intervening blank lines.


#@cli dummy : noarguments
#@cli : You want help? HA!!!
#@cli : $ dummy
   echo "I am a dummy command."

Get help:

gosgood@lydia ~ $ gmic -command dummy.gmic -help dummy
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Import commands from file dummy.gmic', with debug info (1 new, total: 4661).

    You want help? HA!!!

      [#1] dummy


Thanks for the info, Gary, Reptorian. Have to look were it did not function since I prepared me even a special help. I think it might have to do with changes not already in update.gmic OR there is a nice improvement!

#@cli kr_help : _command, _gmic_file(=$_path_rc/update$_version.gmic)
#@cli : Display help (parse_cli ascii,command) optionally from _gmic_file (e. g. external files).
#@cli : Default _command="" _gmic_file=$_path_rc/update$_version.gmic
kr_help : skip "${1=''},${2=$_path_rc/update$_version.gmic}"
  if isfile(['$2'])
    l[] { cimgz:$2 k[0]
    onfail l[] { raw:$2,uint8 k[0] onfail }
    if $! k. fi
  if !$! return fi
  y a y
  parse_cli ascii,$1
  rm v 0 q

Is there a way to read G’MIC codes from .gmic file as a image in G’MIC? I need that so that I can replace my Python toolset used for manipulating G’MIC codes.

I think “it file.gmic” is doing the task!

I mean using a specific command from a .gmic file. Not the whole thing.

That would be a good opportunity to use a Regular Expression to extract functions from a text file. Perhaps there is an expert on the list!

Why not using the tip from @grosgood : command file.gmic e $$function ?

1 Like

Hmm, it doesn’t seem to support newlines. But, it is certainly is something to work with. Places where there is new lines appear to contain 2 spaces.

I think I’ll just use the it .gmic trick instead.

Maybe something like -


cmd2img: skip ${1}

places an n×1 image on the list whose n pixel values are the character codes of the command text.

gosgood@lydia ~ $ gmic -m cmd2img.gmic cmd2img 'colorwheel'
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Import commands from file 'cmd2img.gmic', with debug info (1 new, total: 4661).
[gmic]-1./ Display image [0] = '(99,104,101,99,107,32,36,123,49,61,53,(...)9,32,112,105,120,101,108,115,32,115,1'.
[0] = '(99,104,101,99,107,32,36,123,49(...)32,36,49,32,112,105,120,101,108,115,3:
  size = (239,1,1,1) [956 b of float32].
  data = (99,104,101,99,107,32,36,123,49,61,53,49,(...),99,111,108,111,114,119,104,101,101,108,93,0).
  min = 0, max = 125, mean = 72.6569, std = 33.0001, coords_min = (238,0,0,0), coords_max = (13,0,0,0).

Does this help?

It is closer, but doesn’t really solve the issue of lacking in newlines and additional spaces which are required to preserve readability of code as we humans can’t really parse code similar to computers.