@Helmut_Kaufmann , as it seems you want to process a lot of images, a quite good approach would be to pass the input images image list as a regular expression to your command, rather than loading all images in memory before running the command. If you have hundreds of images with good resolutions to load, that would be painful for your computer.
What I can propose right now is something like this:
foo :
$=arg repeat $# { files 3,${arg{1+$>}} files.=$sep${} sep=, } # Retrieve list of image files
# Loop over all image files.
repeat narg($files) {
arg0 $>,$files file=${}
e " - File: "$file
i $file # Input new image
do_append:=u<0.1 # <- Criterion for determining if images must be appended or not
if $do_append
a x
filename out.jpg,$> filename=${}
o $filename
rm
fi
}
Which can be called from the command line like this:
$ gmic foo \*.jpg
Here, the criterion I chose is simply a threshold on a random value, but feel free to change it to something more meaningful ![]()