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

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Brunus
Posts: 2
Joined: 2017-11-22T03:10:53-07:00
Authentication code: 1152

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

Post 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 !
Last edited by Brunus on 2017-11-22T07:22:56-07:00, edited 1 time in total.
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post 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.
Brunus
Posts: 2
Joined: 2017-11-22T03:10:53-07:00
Authentication code: 1152

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

Post 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/
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

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

Post by Bonzo »

That often happens to me as well - overlook the obvious. Thanks for posting you answer.
Post Reply