Gmic leading zeros in output file name


(Javi Ballester) #1

Hi. I’ve written this reaction-diffusion filter:

iter=1
	-i $1 
	-normalize[-1] 0,1 
	-i $2 
	-repeat $3  
		--gimp_gaussian_blur[-1] 6,0,0,1,0,0,0 
		-blend[-2,-1] grainextract 
		-normalize[-1] 0,255 
		-threshold[-1] 127 
		-normalize[-1] 0,255 
		-repeat $4 
			-smooth[-1] [0],$5 
		-done
		-o. out$iter.png
		iter+=1
		-echo "repeat number: "{$>+1}
	-done 
	-rm[0] 
	-gimp_unsharp 0,5,60,10,0,1,1,1,0,0,0 
	-o t2_000_us.png

I would like the numbers in my output file to have leading zeros, something like this from bash $(printf "t2_%02d.png" $iter), but I can’t find a way to do it.

Can you help me?
Thanks.


(David Tschumperlé) #2

Yes, there is the command filename that creates numbered filenames, so you can write :

   filename=${"filename out.png",$iter}
   -o. $filename

(Javi Ballester) #3

Thanks David.
I’ve had to add a ‘-’ in front of filename command to avoid *** Error (file '/home/ii/.gmic', line #15) *** Unknown filename 'filename'.

This worked for me:

filename=${"-filename out.png",$iter}
-o. $filename

(David Tschumperlé) #4

OK, but that means you are probably using a quite old version of G’MIC. What version do you use ?


(Javi Ballester) #5

It seems so. The one in the repos of Lubuntu 17.10.
Gmic Version 1.7.9.
Installed three days ago :confused:.

Pd: didn’t remembered if I did an apt update before installing, so I’e done it now and gmic is already the newest version (1.7.9+zart-4build1). :joy:


(David Tschumperlé) #6

Ah yes, then maybe I would suggest you install gmic from this PPA instead : https://launchpad.net/~otto-kesselgulasch/+archive/ubuntu/gimp-edge
It is more often updated.


(Javi Ballester) #7

I’ve installed gimp-2.10 and gimp-gmic (v. 2.2.1) but had no luck with command line gmic:

sudo apt install gmic
[sudo] password for ii: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 gmic : Depends: libcurl4 but it is not installable
E: Unable to correct problems, you have held broken packages.

sudo aptitude install gmic
The following packages will be upgraded: 
  gmic{b} 
1 packages upgraded, 0 newly installed, 0 to remove and 110 not upgraded.
Need to get 2.117 kB of archives. After unpacking 305 kB will be used.
The following packages have unmet dependencies:
 gmic : Depends: libcurl4 which is a virtual package and is not provided by any available package

The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     gmic [1.7.9+zart-4build1 (artful, now)]

(Mica) #8

Did you do sudo apt update after installing the PPA? If yes, do sudo apt install curl gmic


(http://4232.cf) #9

Can use filters gimp from gmic?


(Javi Ballester) #10

Shure. I’ve installed gimp-2.10 from that PPA.
I’ve followed your suggestion and installed curl (alone, if I input your command gmic error aborts curl installation) and I’m getting the same error with libcurl4 non provided.

Yes. For me its working as is from command line gmic. Well, now with the filename command pointed by David and in my custom .gmic file:

reaction_diffusion :
	iter=$6
	-i $1
	-split c
	-normalize[0,-1] 0.2,1
	-append[0-2] c
	-i $2 
	-repeat $3  
		--gimp_gaussian_blur[-1] 6,0,0,1,0,0,0 
		-blend[-2,-1] grainextract 
		-normalize[-1] 0,255 
		-threshold[-1] 127 
		-normalize[-1] 0,255 
		-repeat $4 
			-smooth[-1] [0],$5 
		-done 
		filename=${"-filename out.png",$iter}
		-o. $filename
		iter+=1
		-echo "repeat number: "{$>+1}
	-done 
	-rm[0]
	-o. $filename
	-gimp_unsharp 0,5,60,10,0,1,1,1,0,0,0 
	-o out_us.png

I call gmic -reaction_diffusion eigen_tensor_generated_image,image_to_process,iterations,smooth_iters,smooth_amp

I took the idea from here.