That’s not what I mean. Gray, Gray-A, RGB, and RGBA cases. Like, you can load those case within Paint.NET or Krita which always treat them as RGBA float, and use to_automode to convert them into those space. That way, you can address all of those cases at once. That’s precisely how I’m working with the OOBS refactor so that I can test scenarios.
It’s ok I tried with drag n’ drop in Krita and it works. But as expected, 3.2.6 doesn’t know v.
Replaced with floor(u(smthg)) ans it works even though I don’t think it recognizes all the layer modes. But it changed some.
I see. Will try to remember this.
I should keep a few test files around, I’m so used to delete everything haha.
Hello all,
i have a slightly more general question today ![]()
How do you (yourself) (if you do) adapt your filters to take into account G’MiC’s version?
Because i’ve started to use v (and probably others) into some scripts and i know it will break with older versions of G’MIC. I could use $_version but, looks like i’d need to rewrite a lot of things.
Also, don’t you think it could be useful to add G’MIC’s minimum version to the desciption of commands in the reference, at least for future maths expressions or commands? Something like “Added in v3.3.6”, etc.
EDIT : or… how long do you wait before using new features?
I use new features effectively immediately. If that means a rewrite, so be it.
My suggestion is that new features should be used as soon as they appear.
That’s what they’re there for!
Sure, but that means breaking a lot of things for people who have older versions.
And in Krita… i don’t think you can update G’MIC yourself.
When a new feature is guarantee to break it, updates gets disabled for that version.
That’s not totally true. For the users of the G’MIC-Qt plug-in, the filter update is stopped when a new feature introduced in the stdlib breaks the compatibility with older versions.
So even if you use a old version of the plug-in, the filters will continue working. There will just be no filter updates anymore.
And apart from Krita, the other plug-in versions are update quite frequently (particularly thanks to @PDN_GMIC who updates the plug-in binaries for Paint.NET and 8bf very quickly).
I see. So new filters using new features won’t appear in old versions because they wouldn’t work anyway? So if i start an old Debian distro with G’MIC 2.x it won’t get anything beyond that point?
Exactly.
Filter updates are versioned.
Can someone help me with finding the correct way to write this?
I’m building a list with the selected layer modes, but arg doesn’t recognize the list.
The list starts with a coma (because i couldn’t find a condition to remove it before or after the list is filled
), like this:
list=,"addition","darken","difference","divide","dodge","exclusion","grain(...)
But then when i try to use it with arg :
arg $ind$list <<<<<<<<<< does not work
ind:=v(1,$nb)
list..=$ind <<<<<<<< doesn't work either
arg $list
It looks like it sees the whole list as only one item. What would be the correct syntax?
Or is everything wrong anyway?
Here is the command call , script & output lie below:
gmic v 3 ./prawnsushi.gmic sp , pr_laymad 1,0,1,1,1,1,1,1
Full Script & output
pr_laymad:
i,nb,sep=1,0,","
for $i<=$#
{
val=${arg\ $i,$*}
if $val
arg $i,\
"addition","burn","darken","difference","divide","dodge","exclusion","grainextract","grainmerge","hardlight",\
"hardmix","hue","lchlightness","lighten","linearlight","luminance","multiply","negation","overlay","pinlight",\
"reflect","saturation","screen","softlight","subtract","value","vividlight","color","lchcolor","lchchroma",\
"erase","lumadarken","lumalighten","colorerase","merge","lchhue","lchchroma","dissolve"
list.=$sep"\""${}"\""
fi
i,nb+=1,$val
}
foreach {
ind:=v(1,$nb)
arg $ind$list <<<<<<<<<< does not work
mod=${}
opac:=v(50,100) => "mode("$mod"),opacity("$opac"),name("$mod-$opac")"
}
[gmic]./pr_laymad/ Set variables 'i=1', 'nb=0' and 'sep=,'.
[gmic]./pr_laymad/ Start 'for...done' block -> condition '1<=8' holds.
[gmic]./pr_laymad/*for/*substitute/arg/ Set variables 'arg0=arg', 'arg1=1', 'arg2=1', 'arg3=0', 'arg4=1', 'arg5=1', 'arg6=1', 'ar(...).
[gmic]./pr_laymad/*for/*substitute/arg/ Set status to '1'.
[gmic]./pr_laymad/*for/ Set local variable 'val=1'.
[gmic]./pr_laymad/*for/*if/ Start 'if...endif' block -> condition '1' holds.
[gmic]./pr_laymad/*for/*if/arg/ Set variables 'arg0=arg', 'arg1=1', 'arg2=addition', 'arg3=burn', 'arg4=darken', 'arg5=di(...).
[gmic]./pr_laymad/*for/*if/arg/ Set status to 'addition'.
[gmic]./pr_laymad/*for/*if/ Set local variable 'list=,"addition"'.
[gmic]./pr_laymad/*for/*if/ End 'if...endif' block.
[gmic]./pr_laymad/*for/ Set variables 'i+=1,1'->'2' and 'nb+=1,1'->'1'.
[gmic]./pr_laymad/*for/ Go back to 'for' command -> condition '2<=8' holds.
[gmic]./pr_laymad/*for/*substitute/arg/ Set variables 'arg0=arg', 'arg1=2', 'arg2=1', 'arg3=0', 'arg4=1', 'arg5=1', 'arg6=1', 'ar(...).
[gmic]./pr_laymad/*for/*substitute/arg/ Set status to '0'.
[gmic]./pr_laymad/*for/ Set local variable 'val=0'.
[gmic]./pr_laymad/*for/*if/ Start 'if...endif' block -> condition '0' does not hold.
[gmic]./pr_laymad/*for/*if/ End 'if...endif' block.
[gmic]./pr_laymad/*for/ Set variables 'i+=1,0'->'3' and 'nb+=1,0'->'1'.
[gmic]./pr_laymad/*for/ Go back to 'for' command -> condition '3<=8' holds.
[gmic]./pr_laymad/*for/*substitute/arg/ Set variables 'arg0=arg', 'arg1=3', 'arg2=1', 'arg3=0', 'arg4=1', 'arg5=1', 'arg6=1', 'ar(...).
[gmic]./pr_laymad/*for/*substitute/arg/ Set status to '1'.
[gmic]./pr_laymad/*for/ Set local variable 'val=1'.
[gmic]./pr_laymad/*for/*if/ Start 'if...endif' block -> condition '1' holds.
[gmic]./pr_laymad/*for/*if/arg/ Set variables 'arg0=arg', 'arg1=3', 'arg2=addition', 'arg3=burn', 'arg4=darken', 'arg5=di(...).
[gmic]./pr_laymad/*for/*if/arg/ Set status to 'darken'.
[gmic]./pr_laymad/*for/*if/ Set local variable 'list=,"addition","darken"'.
[gmic]./pr_laymad/*for/*if/ End 'if...endif' block.
[gmic]./pr_laymad/*for/ Set variables 'i+=1,1'->'4' and 'nb+=1,1'->'2'.
[gmic]./pr_laymad/*for/ Go back to 'for' command -> condition '4<=8' holds.
[gmic]./pr_laymad/*for/*substitute/arg/ Set variables 'arg0=arg', 'arg1=4', 'arg2=1', 'arg3=0', 'arg4=1', 'arg5=1', 'arg6=1', 'ar(...).
[gmic]./pr_laymad/*for/*substitute/arg/ Set status to '1'.
[gmic]./pr_laymad/*for/ Set local variable 'val=1'.
[gmic]./pr_laymad/*for/*if/ Start 'if...endif' block -> condition '1' holds.
[gmic]./pr_laymad/*for/*if/arg/ Set variables 'arg0=arg', 'arg1=4', 'arg2=addition', 'arg3=burn', 'arg4=darken', 'arg5=di(...).
[gmic]./pr_laymad/*for/*if/arg/ Set status to 'difference'.
[gmic]./pr_laymad/*for/*if/ Set local variable 'list=,"addition","darken","difference"'.
[gmic]./pr_laymad/*for/*if/ End 'if...endif' block.
[gmic]./pr_laymad/*for/ Set variables 'i+=1,1'->'5' and 'nb+=1,1'->'3'.
[gmic]./pr_laymad/*for/ Go back to 'for' command -> condition '5<=8' holds.
[gmic]./pr_laymad/*for/*substitute/arg/ Set variables 'arg0=arg', 'arg1=5', 'arg2=1', 'arg3=0', 'arg4=1', 'arg5=1', 'arg6=1', 'ar(...).
[gmic]./pr_laymad/*for/*substitute/arg/ Set status to '1'.
[gmic]./pr_laymad/*for/ Set local variable 'val=1'.
[gmic]./pr_laymad/*for/*if/ Start 'if...endif' block -> condition '1' holds.
[gmic]./pr_laymad/*for/*if/arg/ Set variables 'arg0=arg', 'arg1=5', 'arg2=addition', 'arg3=burn', 'arg4=darken', 'arg5=di(...).
[gmic]./pr_laymad/*for/*if/arg/ Set status to 'divide'.
[gmic]./pr_laymad/*for/*if/ Set local variable 'list=,"addition","darken","difference","divide"'.
[gmic]./pr_laymad/*for/*if/ End 'if...endif' block.
[gmic]./pr_laymad/*for/ Set variables 'i+=1,1'->'6' and 'nb+=1,1'->'4'.
[gmic]./pr_laymad/*for/ Go back to 'for' command -> condition '6<=8' holds.
[gmic]./pr_laymad/*for/*substitute/arg/ Set variables 'arg0=arg', 'arg1=6', 'arg2=1', 'arg3=0', 'arg4=1', 'arg5=1', 'arg6=1', 'ar(...).
[gmic]./pr_laymad/*for/*substitute/arg/ Set status to '1'.
[gmic]./pr_laymad/*for/ Set local variable 'val=1'.
[gmic]./pr_laymad/*for/*if/ Start 'if...endif' block -> condition '1' holds.
[gmic]./pr_laymad/*for/*if/arg/ Set variables 'arg0=arg', 'arg1=6', 'arg2=addition', 'arg3=burn', 'arg4=darken', 'arg5=di(...).
[gmic]./pr_laymad/*for/*if/arg/ Set status to 'dodge'.
[gmic]./pr_laymad/*for/*if/ Set local variable 'list=,"addition","darken","difference","divide","dodge"'.
[gmic]./pr_laymad/*for/*if/ End 'if...endif' block.
[gmic]./pr_laymad/*for/ Set variables 'i+=1,1'->'7' and 'nb+=1,1'->'5'.
[gmic]./pr_laymad/*for/ Go back to 'for' command -> condition '7<=8' holds.
[gmic]./pr_laymad/*for/*substitute/arg/ Set variables 'arg0=arg', 'arg1=7', 'arg2=1', 'arg3=0', 'arg4=1', 'arg5=1', 'arg6=1', 'ar(...).
[gmic]./pr_laymad/*for/*substitute/arg/ Set status to '1'.
[gmic]./pr_laymad/*for/ Set local variable 'val=1'.
[gmic]./pr_laymad/*for/*if/ Start 'if...endif' block -> condition '1' holds.
[gmic]./pr_laymad/*for/*if/arg/ Set variables 'arg0=arg', 'arg1=7', 'arg2=addition', 'arg3=burn', 'arg4=darken', 'arg5=di(...).
[gmic]./pr_laymad/*for/*if/arg/ Set status to 'exclusion'.
[gmic]./pr_laymad/*for/*if/ Set local variable 'list=,"addition","darken","difference","divide","dodge","exclusion"'.
[gmic]./pr_laymad/*for/*if/ End 'if...endif' block.
[gmic]./pr_laymad/*for/ Set variables 'i+=1,1'->'8' and 'nb+=1,1'->'6'.
[gmic]./pr_laymad/*for/ Go back to 'for' command -> condition '8<=8' holds.
[gmic]./pr_laymad/*for/*substitute/arg/ Set variables 'arg0=arg', 'arg1=8', 'arg2=1', 'arg3=0', 'arg4=1', 'arg5=1', 'arg6=1', 'ar(...).
[gmic]./pr_laymad/*for/*substitute/arg/ Set status to '1'.
[gmic]./pr_laymad/*for/ Set local variable 'val=1'.
[gmic]./pr_laymad/*for/*if/ Start 'if...endif' block -> condition '1' holds.
[gmic]./pr_laymad/*for/*if/arg/ Set variables 'arg0=arg', 'arg1=8', 'arg2=addition', 'arg3=burn', 'arg4=darken', 'arg5=di(...).
[gmic]./pr_laymad/*for/*if/arg/ Set status to 'grainextract'.
[gmic]./pr_laymad/*for/*if/ Set local variable 'list=,"addition","darken","difference","divide","dodge","exclusion","grain(...).
[gmic]./pr_laymad/*for/*if/ End 'if...endif' block.
[gmic]./pr_laymad/*for/ Set variables 'i+=1,1'->'9' and 'nb+=1,1'->'7'.
[gmic]./pr_laymad/*for/ Go back to 'for' command -> condition '9<=8' does not hold.
[gmic]./pr_laymad/*foreach/ Start 'foreach...done' block, with image [0].
[gmic]./pr_laymad/*foreach/ Set local variable 'ind:=v(1,7)'->'6'.
[gmic]./pr_laymad/*foreach/arg/ *** Error *** Command 'check': Invalid argument 'isint(6,"addition","darken","d(...)"exclusion","grainextract",1)': Unrecognized item '"addition"' in expression 'isint(6,"addition","darken","difference","divide","dodge","(...)'.
EDIT : got it working with this :
list.={``${},} in the for loop instead of list.=$sep"\""${}"\""
and
arg $ind,{/$list} in the foreach loop instead of arg $ind$list
But i have a trailing comma at the end of the list. Gotta find out how to remove it…
(arg doesn’t seem to care about the trailing comma though since it’ll never be “summoned”)
Having fun.
foo :
list="addition","darken","difference","divide","dodge","exclusion","grainmerge"
mode=${"arg {v(1,narg("$list"))},"$list}
Oh my. Quelle est donc cette diablerie?
Somehow i always feel like i’m digging my own grave.
(Still happy that i made my own stuff work, for once)
My solution looks like this:
list_of_blending_modes=add,alpha,and,average,burn,darken,difference,divide,dodge,exclusion,freeze,grainextract,grainmerge,hardlight,hardmix,interpolation,lighten,linearburn,linearlight,multiply,normal,negation,or,overlay,pinlight,reflect,screen,shapeaverage,softburn,softdodge,softlight,stamp,subtract,vividlight,xor
num_of_blending_modes={narg($list_of_blending_modes)}
$list_of_blending_modes={expr('x',$num_of_blending_modes)}
This way, I can use either ‘burn’ or 3 as CLI arguments.
But my list isn’t set in stone though, it is set by the GUI and the 1st loop. 3 could be burn or difference or whatever was checked.
All the gui elements are booleans, and you can uncheck whatever you want. ( All unchecked throws an error but it’s ok for now)
pr_laymad:
i,nb,sep=1,0,","
for $i<=$#
{
val=${arg $i,$*}
if $val
arg $i,\
"addition","burn","darken","difference","divide","dodge","exclusion","grainextract","grainmerge","hardlight",\
"hardmix","hue","lchlightness","lighten","linearlight","luminance","multiply","negation","overlay","pinlight",\
"reflect","saturation","screen","softlight","subtract","value","vividlight","color","lchcolor","lchchroma",\
"erase","lumadarken","lumalighten","colorerase","merge","lchhue","lchchroma","dissolve"
list.={``${},}
fi
i,nb+=1,$val
}
I could use narg after this though instead of $nb.
General remark: if you are not already doing so, consider using debug from time to time. See Debuggery and Debug dumping. In this mode, G’MIC tells you precisely how it is itemizing a pipeline, both as what is written at the command line and the pipelines into which custom commands resolve. 90% of G’MIC mysteries resolve to the difference between how G’MIC itemizes a pipeline and how people think G’MIC itemizes a pipeline.
Have fun!
@grosgood yes I do use debug, but it’s easier when it’s an image problem ( value, list) than with syntax.
I keep reading the docs in all directions, but I’m still unsure what to use. I managed to find this list.={``${},} and this arg $ind,{/$list} but it took me some time. I’ve even added one more slash {/$list/}to prevent syntax highlighting trouble in Kate (Ruby mode). Seems to work.
Now i’m trying to find out how to remove the trailing “,” from my list. Don’t know what to use. I’ve seen something here using str or string (or was it?). to print parts of a string, but i can’t find it now… Thought i had it bookmarked, but looks like it’s not there.
When the stars align, you can get some kind of smiling cartoon face? A white haired woman ?

Marylin?
![]()
Try this change:
pr_laymad:
i,nb,sep=1,0,
for $i<=$#
{
val=${arg\ $i,$*}
if $val
arg $i,\
"addition","burn","darken","difference","divide","dodge","exclusion","grainextract","grainmerge","hardlight",\
"hardmix","hue","lchlightness","lighten","linearlight","luminance","multiply","negation","overlay","pinlight",\
"reflect","saturation","screen","softlight","subtract","value","vividlight","color","lchcolor","lchchroma",\
"erase","lumadarken","lumalighten","colorerase","merge","lchhue","lchchroma","dissolve"
list.=$sep${}
fi
i,nb+=1,$val
sep=,
}
Note the two sep and what that does.

