Page 1 of 1

[fixed] error message on -distort when running a script without sh call

Posted: 2017-11-22T03:32:19-07:00
by Brunus
Hi all,

I made a shell script of almost 300 lines that create images using ImageMagick.
I run this script on a Debian Linux system.
My first line is : #!/bin/bash

Everything works well when I launch the script with the command line : sh myscript.sh arg
But if I lauch the script without sh it cast an error on a -distort function:
./myscript.sh arg
convert-im6.q16: invalid argument for option Perspective : 'require at least 4 CPs' @ error/distort.c/GenerateCoefficients/791.

The lines of the -distort call :

Code: Select all

convert front_large.png -bordercolor grey -border 3 -background 'rgba(0,0,0,0)' \
		-virtual-pixel transparent +distort Perspective "0,0 0,${hgt}  0,${h} 0,${hgb}  ${w},0 ${w},${0}  ${w},${h} ${w},${h}" \
		-gravity West -extent ${we}x${he} \
		-fill white -stroke grey -strokewidth 3 -draw "rectangle ${r1x},75 ${r1w},${r1h}" \
		-fill white -stroke grey -strokewidth 3 -draw "rectangle ${r2x},85 ${r2w},${r2h}" \
		-fill white -stroke grey -strokewidth 3 -draw "rectangle ${r3x},95 ${r3w},${r3h}" \
		+repage tmp1_output.png;
The values for the variables h, w, hgt and hgb are the same when I launch the script with or without sh.

Any idea on what I could do to fix the problem when I'm lauching the script without sh ?

Thanks !

Re: error message on -distort when running a script without sh call

Posted: 2017-11-22T03:52:44-07:00
by Bonzo
Linux systems need the parentheses escaped; try changing rgba(0,0,0,0) to rgba\(0,0,0,0\)

Also I would try your code with fixed data rather than variables to prove it works.

Re: error message on -distort when running a script without sh call

Posted: 2017-11-22T07:22:10-07:00
by Brunus
Bonzo wrote: 2017-11-22T03:52:44-07:00 Linux systems need the parentheses escaped; try changing rgba(0,0,0,0) to rgba\(0,0,0,0\)

Also I would try your code with fixed data rather than variables to prove it works.
Thanks Bonzo, but it's not that and it cast one more error :
convert-im6.q16: unrecognized color `rgba\(0,0,0,0)\'

But...THANKS !
I followed your advise, I managed to replace variables by legit values and...while editing the line I seen where was the problem...

Code: Select all

-virtual-pixel transparent +distort Perspective "0,0 0,${hgt}  0,${h} 0,${hgb}  ${w},0 ${w},${0}  ${w},${h} ${w},${h}"
${0} really ? :D
Damn...I rod this line so many times and I did not see it before !

Fixed ! \o/

Re: [fixed] error message on -distort when running a script without sh call

Posted: 2017-11-22T08:33:29-07:00
by Bonzo
That often happens to me as well - overlook the obvious. Thanks for posting you answer.