Useful extension of Substituting Expressions

This is somewhere I’ve already written in the changelog, but I think this is worth discussing about it.
Yesterday, I’ve introduced an extension to the Substituting Expressions, as well as a new “Input String”. Here is the copy/paste of what I wrote in the Changelog:

  • [core] Most substituting expressions between braces {} can now specify an delimiter option, that delimits multiple values coming from a substitution (e.g. {[1,2,3]:;} is substituted as 1;2;3 and {'foo:^} by 102^111^111). Accepted delimiters are , (default), ;, /, ^ and ’ ’ (space).

  • [core] New input expressions ('string') and ('string':delimiter) now available, to create images containing the character codes composing the string (equivalent to ({'string'}) and ({'string':delimiter}) where delimiter can be , (default), ;, / or ^). For this special expression, delimiter can also be specified as x,y,z or v to set the main image orientation.

So, for instance:

$ gmic run "('foo':y)"
[gmic]-0./ Start G'MIC interpreter.
[gmic]-1./ Display image [0] = '('foo':y)'.
[0] = '('foo':y)':
  size = (1,3,1,1) [12 b of floats].
  data = (102;111;111).
  min = 102, max = 111, mean = 108, std = 5.19615, coords_min = (0,0,0,0), coords_max = (0,1,0,0).
[gmic]-1./ End G'MIC interpreter.

allows to easily creates “string-valued” images along axis y.


$ gmic m "foo : echo {0,@1-10:/}" sp lena foo
[gmic]-0./ Start G'MIC interpreter.
[gmic]-0./ Import custom commands from expression 'foo : echo {0,@1-10:/}' (1 replaced, total: 4174).
[gmic]-1./ Input sample image 'lena' (1 image 512x512x1x3).
[gmic]-1./foo/ 225/223/223/225/225/225/223/225/223/223
[gmic]-1./ Display image [0] = 'lena'.

Note that this doesn’t break the compatibility with previous substituting expressions, it just extends them in a way we get more flexibility for writing scripts.