gmic called from inside a perl script , substitution problem


#1

hello
I’m trying to execute a gmic command inside a perl script and got errors concerning item substitution.

when I launch the command in a bash console it works fine
/usr/bin/gmic originales/ima.{0068…0072}.png -append z -blur_z 2 -split z -o[2] timeblur/ima_tb.0070.png
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ Input file ‘originales/ima.0068.png’ at position 0 (1 image 960x720x1x3).
[gmic]-1./ Input file ‘originales/ima.0069.png’ at position 1 (1 image 960x720x1x3).
[gmic]-2./ Input file ‘originales/ima.0070.png’ at position 2 (1 image 960x720x1x3).
[gmic]-3./ Input file ‘originales/ima.0071.png’ at position 3 (1 image 960x720x1x3).
[gmic]-4./ Input file ‘originales/ima.0072.png’ at position 4 (1 image 960x720x1x3).
[gmic]-5./ Append images [0,1,2,3,4] along the ‘z’-axis, with alignment 0.
[gmic]-1./ Blur image [0] along the z-axis, with sigma 2 and neumann boundary conditions.
[gmic]-1./ Split image [0] along the ‘z’-axis.
[gmic]-5./ Output image [2] as png file ‘timeblur/ima_tb.0070.png’ (1 image 960x720x1x3).
[gmic]-5./ End G’MIC interpreter.

when I launch it inside a perl script with a system() command:

print $cmd;
system $cmd;

/usr/bin/gmic originales/ima.{0068…0072}.png -append z -blur_z 2 -split z -o[2] timeblur/ima_tb.0070.png
[gmic]-0./ Start G’MIC interpreter.
[gmic]-0./ *** Error *** Item substitution ‘{0068…0072}’: Unrecognized item ‘0068…0072’ in expression ‘0068…0072’.

if somebody has a clue…I looked around in the perl world but without success for the moment
luc

this is on ubuntu 16.04 . bash env


(Karsten R) #2

Hi

“originales/ima.{0068…0072}.png” is a bash construct. It is not resolved by gmic but by bash. I think you have it to reformulate in perl, either by giving the list or by using perl syntax.

Regards
Karsten


#3

@luluxXX G’MIC also has -input_glob.


#4

yes I’m using the system() command in perl : from docs
The system() function executes an operating system command by forking a child process and waiting for the child process to complete

… so it should work …


(Karsten R) #5

Hmm, I don’t know perl enough, still system() does not mean bash! Either try “bash gmic …” or the tip from @afre “gmic -input_glob …”


#6

well I reconstructed the image list as an array and pass it to the gmic command.it solved my problem.thank you