|
List Info
Thread: convert called from php
|
|
| convert called from php |

|
2006-11-21 17:21:09 |
Hi everybody,
I'm trying to use convert from a php script using the php
exec()
function. When I give a simple convert command like
~/util/bin/convert -size 195x152 xc: -fx 'i/w' carte_p.png
it works. But when replacing the 'i/w' by something much
more
complicated, the command fails with a "9" return
code. The strange
thing is that when issuing the exact same command under a
bash shell
on the server (through an ssh connection), everything works
as expected.
The php server is configured with a 50000 max execution time
and the
privileges of the files involved are -rwxr-xr-x, which
should be ok...
Perhaps someone has an idea...
Thanks
Damir
====================================
Damir Buskulic, Universite de Savoie/LAPP
B.P. 110, F-74941 Annecy-le-Vieux Cedex, FRANCE
Tel : +33 (0)450091600
====================================
_______________________________________________
Magick-users mailing list
Magick-users imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick
-users
|
|
| convert called from php |

|
2006-11-22 03:50:27 |
Damir Buskulic on wrote...
| Hi everybody,
|
| I'm trying to use convert from a php script using the php
exec()
| function. When I give a simple convert command like
|
| ~/util/bin/convert -size 195x152 xc: -fx 'i/w' carte_p.png
|
| it works. But when replacing the 'i/w' by something much
more
| complicated, the command fails with a "9" return
code. The strange
| thing is that when issuing the exact same command under a
bash shell
| on the server (through an ssh connection), everything
works as expected.
| The php server is configured with a 50000 max execution
time and the
| privileges of the files involved are -rwxr-xr-x, which
should be ok...
|
| Perhaps someone has an idea...
It is probably a quoting problem from PHP. Can you give a
snipet of the
PHP code you used to make the call, and an exampe of the
'change' you
make.
Anthony Thyssen ( System Programmer ) <A.Thyssen griffith.edu.au>
-----------------------------------------------------------
------------------
To think is human, to compute, divine.
-----------------------------------------------------------
------------------
Anthony's Home is his Castle http://www.cit.gu.
edu.au/~anthony/
_______________________________________________
Magick-users mailing list
Magick-users imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick
-users
|
|
| convert called from php |

|
2006-11-22 14:17:05 |
Hi Anthony and Justin,
Indeed, I tried to use a simple shell script and call it
from php.
Didn't work either.
Herre is a snippet of the test code I'm using :
// $commtest = '~/util/bin/convert -size 195x152 xc:
-fx 'cc=
(i-30)*(80)-(j-50)*(-10);bb=(-9200)+(i-30)*(55)-(j-50)*(-90)
;(-bb-sqrt
(bb*bb-(-12000)*cc))/2/(-3000)' ~/im_virg/test_p.png';
$commtest = "deform.sh";
// $commtest = '~/util/bin/convert -size 195x152 xc:
-fx 'i/w'
~/im_virg/test_p.png';
exec($commtest,$output);
I also tried with system(). Same thing...
Thanks anyway for your help.
Damir
Le 22 nov. 06 à 04:50, Anthony Thyssen a écrit :
> Damir Buskulic on wrote...
> | Hi everybody,
> |
> | I'm trying to use convert from a php script using the
php exec()
> | function. When I give a simple convert command like
> |
> | ~/util/bin/convert -size 195x152 xc: -fx 'i/w'
carte_p.png
> |
> | it works. But when replacing the 'i/w' by something
much more
> | complicated, the command fails with a "9"
return code. The strange
> | thing is that when issuing the exact same command
under a bash shell
> | on the server (through an ssh connection), everything
works as
> expected.
> | The php server is configured with a 50000 max
execution time and the
> | privileges of the files involved are -rwxr-xr-x,
which should be
> ok...
> |
> | Perhaps someone has an idea...
>
> It is probably a quoting problem from PHP. Can you
give a snipet
> of the
> PHP code you used to make the call, and an exampe of
the 'change' you
> make.
>
> Anthony Thyssen ( System Programmer )
<A.Thyssen griffith.edu.au>
>
>
------------------------------------------------------------
----------
> -------
> To think is human, to compute, divine.
>
>
------------------------------------------------------------
----------
> -------
> Anthony's Home is his Castle http://www.cit.gu.edu.au/
a>
> ~anthony/
====================================
Damir Buskulic, Universite de Savoie/LAPP
B.P. 110, F-74941 Annecy-le-Vieux Cedex, FRANCE
Tel : +33 (0)450091600
====================================
_______________________________________________
Magick-users mailing list
Magick-users imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick
-users
|
|
| convert called from php |

|
2006-11-22 23:57:33 |
Damir Buskulic on wrote...
| Hi Anthony and Justin,
|
| Indeed, I tried to use a simple shell script and call it
from php.
| Didn't work either.
| Herre is a snippet of the test code I'm using :
|
| // $commtest = '~/util/bin/convert -size 195x152 xc:
-fx 'cc=
|
(i-30)*(80)-(j-50)*(-10);bb=(-9200)+(i-30)*(55)-(j-50)*(-90)
;(-bb-sqrt
| (bb*bb-(-12000)*cc))/2/(-3000)' ~/im_virg/test_p.png';
| $commtest = "deform.sh";
| // $commtest = '~/util/bin/convert -size 195x152 xc:
-fx 'i/w'
| ~/im_virg/test_p.png';
| exec($commtest,$output);
|
And it works fine from the command line?
I ask because the "var=" was a very recent
addition to the -fx
expressions, that is only availabe in the latest IM's
It just makes the calculations that much easier.
The output image however (command line) is very interesting
though
Hmm simplifying the maths...
convert -size 195x152 xc:
-fx 'cc=(i-30)*80+(j-50)*10;
bb=(i-30)*55+(j-50)*90-9200;
(bb+sqrt(bb*bb+12000*cc))/6000'
test_p.png
What are you using it for? The formula looks like it is
mento to be
centered on pixel 30,50 but the multipliers moves that
point to another
location with weird quadratic effects.
Back to the problem at hand...
I would not use '~' in a system command.
Also I believe you should be using backquotes to execute
it...
EG: $var = `....`
In which case you don't need to escape the signgle quotes.
For system you can use one quote " and then you don't
need to escape the
other quote ' inside. (or swap them) EG:
" '...' " OR '
"...." '
| Thanks anyway for your help.
|
your welcome.
let me know the results.
Especially as it looks like you are developing a gradient
for a
positional distortion map. I am very interested in what
people come up
with for this.
Anthony Thyssen ( System Programmer ) <A.Thyssen griffith.edu.au>
-----------------------------------------------------------
------------------
As a computer, I find your faith in technology
amusing.
-----------------------------------------------------------
------------------
Anthony's Home is his Castle http://www.cit.gu.
edu.au/~anthony/
_______________________________________________
Magick-users mailing list
Magick-users imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick
-users
|
|
| convert called from php |

|
2006-11-23 14:12:21 |
Hi Anthony,
> | // $commtest = '~/util/bin/convert -size 195x152
xc: -fx 'cc=
> |
(i-30)*(80)-(j-50)*(-10);bb=(-9200)+(i-30)*(55)-(j-50)*(-90)
;(-bb-
> sqrt
> | (bb*bb-(-12000)*cc))/2/(-3000)'
~/im_virg/test_p.png';
> | $commtest = "deform.sh";
> | // $commtest = '~/util/bin/convert -size 195x152
xc: -fx 'i/
> w'
> | ~/im_virg/test_p.png';
> | exec($commtest,$output);
> |
> And it works fine from the command line?
> I ask because the "var=" was a very recent
addition to the -fx
> expressions, that is only availabe in the latest IM's
Yes, I compiled the 6.3.0 version of IM (I think...)
> What are you using it for? The formula looks like it
is mento to be
> centered on pixel 30,50 but the multipliers moves that
point to
> another
> location with weird quadratic effects.
Surprise... If I
succeed, I'll send you the result, promise
> I would not use '~' in a system command.
I tried, that is not the problem
> Also I believe you should be using backquotes to
execute it...
> EG: $var = `....`
> In which case you don't need to escape the signgle
quotes.
> For system you can use one quote " and then you
don't need to
> escape the
> other quote ' inside. (or swap them) EG:
> " '...' " OR '
"...." '
The quotes does not seem to be a problem. Launched from php,
the
following command works
$commtest = '~/util/bin/convert -size 195x152 xc: -fx
'sqrt((-9200+
(i-30)*55+(j-50)*90)*(-9200+(i-30)*55+(j-50)*90)+12000*((i-3
0)*80+
(j-50)*10))/6000' test_p_linx.png';
and generates a file of roughly 12 kB, while the following :
$commtest = '~/util/bin/convert -size 200x200 xc: -fx
'sqrt((-9200+
(i-30)*55+(j-50)*90)*(-9200+(i-30)*55+(j-50)*90)+12000*((i-3
0)*80+
(j-50)*10))/6000' test_p_linx.png';
doesn't generate anything. See the difference ? Just the
size of the
generated image. Again, both work from an ssh session. I
don't see
why this would make any difference.
> Especially as it looks like you are developing a
gradient for a
> positional distortion map. I am very interested in
what people
> come up
> with for this.
It doesn't work for the moment...
Cheers
Damir
====================================
Damir Buskulic, Universite de Savoie/LAPP
B.P. 110, F-74941 Annecy-le-Vieux Cedex, FRANCE
Tel : +33 (0)450091600
====================================
_______________________________________________
Magick-users mailing list
Magick-users imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick
-users
|
|
| convert called from php |

|
2006-11-24 01:08:02 |
Damir Buskulic on wrote...
| > What are you using it for? The formula looks like it
is mento to be
| > centered on pixel 30,50 but the multipliers moves
that point to
| > another
| > location with weird quadratic effects.
|
| Surprise... If I
succeed, I'll send you the result, promise
|
I'll hold you to that
| The quotes does not seem to be a problem. Launched from
php, the
| following command works
| $commtest = '~/util/bin/convert -size 195x152 xc: -fx
'sqrt((-9200+
|
(i-30)*55+(j-50)*90)*(-9200+(i-30)*55+(j-50)*90)+12000*((i-3
0)*80+
| (j-50)*10))/6000' test_p_linx.png';
|
| and generates a file of roughly 12 kB, while the following
:
|
| $commtest = '~/util/bin/convert -size 200x200 xc: -fx
'sqrt((-9200+
|
(i-30)*55+(j-50)*90)*(-9200+(i-30)*55+(j-50)*90)+12000*((i-3
0)*80+
| (j-50)*10))/6000' test_p_linx.png';
|
| doesn't generate anything. See the difference ? Just the
size of the
| generated image. Again, both work from an ssh session. I
don't see
| why this would make any difference.
|
Hmmm. Same formula so it isn't parsing. First though was a
division by
zero but you don't have a variable divider. You do have a
sqrt
however...
Could you be generating a negative element in the sqrt().
A negative square root produces a 'complex number' with an
immaginary
or "sqrt(-1)" component, which IM can not deal
with.
This is a typical problem with quadratic functions, which
can have
immaginary solutions.
Add a debug() statment at the start of the -fx formula and
see what
pixel the function breaks down. If it does break. IM should
output an
error and do nothing, but that may not be happening.
Alturnativally you can remove the 'image size' from the
formula by
adjusting and scaling the pixel coordinates into a 0 to 1
range by
replacing i with i/w and j with j/h
(or better still i/(w-1) and j/(h-1))
That way the result is scaled to the image. You can even
make it easier
by using some variable assignments...
-fx 'xx=i/w-.25; yy=j/h-.5; sqrt(.....)'
Using assigments will also remove the repeated segments,
simplify the
formula, make debugging easier, and speed up the
calculations.
Anthony Thyssen ( System Programmer ) <A.Thyssen griffith.edu.au>
-----------------------------------------------------------
------------------
"[A computer is] like an Old Testament god,
with a lot of rules and no mercy." ---
Joseph Campbell
-----------------------------------------------------------
------------------
Anthony's Home is his Castle http://www.cit.gu.
edu.au/~anthony/
_______________________________________________
Magick-users mailing list
Magick-users imagemagick.org
http://studio.imagemagick.org/mailman/listinfo/magick
-users
|
|
[1-6]
|
|