Release of G'MIC 2.6

This is the changelog for the release of the 2.6 version of the G’MIC software.
It lists all new features and changes done since the latest major version 2.5(.7).

What is G’MIC?

G’MIC (GREYC’s Magic for Image Computing) is a full-featured open-source framework for image processing. It provides several different user interfaces to convert/manipulate/filter/visualize generic image datasets, ranging from 1D scalar signals to 3D+t sequences of multi-spectral volumetric images, thus including 2D color images.

supportus



What’s new in version 2.6?

We had one major change in the interpreter syntax, which makes new developed filters incompatible with the previous branch 2.5.x, hence the new branch 2.6.x (see Improvements below).

Improvements / Changes:

  • Commands if, elif, while and for that control program flow now accept an expression as its argument, which is automatically evaluated if needed (if specified condition is not given explicitly as a boolean). This is also the case for command repeat. As a result, this allows to remove a lot of opening/closing braces in the code of the filters, for more readability. For instance, the code below is now valid:
foo:
  if $!<3  # Rather than 'if {$!<3}'
    repeat 2*$!+3,var echo $var done # Rather than 'repeat {2*$!+3}'
  fi
  • Commands if,elif, while and for do not test the existence of a file anymore. If the provided condition is not a boolean or a valid expression, an exception is thrown.
    To test the existence of a file or a folder, use isfile() and isdir():
foo:
  filename="C:\Folder\filename.ext"
  if isdir(['{/$filename}'])  # Rather than 'if $filename' 
    ...
  fi 

The new expression is more verbose, but this avoids mistakes like if (x+3*(y+2) (here a closing parenthesis is missing in the expression, and in previous versions this "condition’ was silently evaluated to false, as file if (x+3*(y+2) does not exist, now this throws an error).

  • Man pages have been improved.

  • Math function isval() is replaced by isnumber(). This functions tests if its argument is an explicit number, e.g. isnumber(0.3) = true , and isnumber(pi) = false .

  • Math function isval() still exists, but now tests if its argument is a valid math expression, e.g. isval([pi,0]) = true and isval(foo://)=false.

  • Multi-line comments are now supported to document .gmic files. A multi-line comment is a comment written with multiple lines but intended to be in a single line, such as:

#@cli Default values: 'arg1=0', 'arg2=0', \
# 'arg3=0' and 'arg4=0'.

which is equivalent to

#@cli Default values: 'arg1=0', 'arg2=0', 'arg3=0' and 'arg4=0'.

This is useful for documenting default values and command definitions where there are a lot of arguments involved.

Bug fixes:

  • Command parallel now better manages threads that throw exceptions (e.g. with command error). This was causing hang sometimes in preview G’MIC versions, due to multiple thread cancellation requests done at the same time.

  • Commands can be invoked now with an arbitrary large image selection. Previously, the string describing the image selection was limited to 256 characters.

2 Likes

Just wondering: what is the purpose of labelling the loop count?

For a single loop, there is indeed $> for the counter, but in case of nested loops it can be nice to have named counters:

foo:
  sp david,32
  repeat h,y
    repeat w,x
      = 0,$x,$y
    done
  done

It didn’t occur to me: I normally stay away from nested loops. I also didn’t know that = 0,$x,$y could be done like that. I would do it like this sh 0 fc. 0 rm. Could you point me to where it is in the manual? I still find it hard to find things in the references.

And you are right, G’MIC being an interpreted language, nested loops should be avoided as much as you can, particularly if it involves many iterations, for performance reasons.

That’s indeed the best way to do it! My example was just an example to show there can be some particular cases where named variables in loops may be useful. Not a very good example in this case, but I wanted to keep it simple.
But one good suggestion : don’t do XY loops over image pixels like this !

Actually, I was asking about = 0,$x,$y. I wasn’t aware that this syntax could set a value to a coordinate. Don’t know where it is in the manual.

Ah ok, that’s because = is also the name of a shortcut, for command set
(https://gmic.eu/reference.shtml#set)

Thanks. There are literally thousands of = signs on the page. I mentioned this before: the removal of single quotes in the formatting has made it much harder to find things. E.g., before, I could do a search on ‘=’.

Try “gmic h =” and find the answer!

1 Like

It’s true that I also find that using the cli tool gmic to get the reference for a particular command is easier !

True. I guess I am always trying to be in another’s shoes, so the typical user would go to the docs for help. :wink:

No, no, I have the problems too to find something in the documentation. My way is always searching for commands e.g. in strange scripts, from David, to use the cli gmic with help first. If that fails I am searching in the reference text file generated by “gmic h”! The disadvantage is that help delivers only the the result of gmic_stdlib.gmic, the corresponding script file update.gmic used in background is much larger (and there are of course the gui custom functions too)

Speaking of gmic help [command], I find that it depends on the command. Sometimes gmic [command] reveals more info; other times, nothing.

Any example ?

I bit off topic, but I remember that there are company interest in using GMIC sometime ago, how was it?

Got no news :frowning:

Actually the preview gmic 2.6.0 does not show the help for all commands

gmic h terminates with “same aspect than those illustrated in the example codes.” in chapter 12.

specific help works!

I’m using the last git source on Mac

Hum… it works for me. Could you try a make clean before recompiling make cli ?

No change!
I did “(cd ~/sw/gmic/src/; make clean ; make -B cli “SUBLIBS=-lX11” || exit)”