Page 1 of 1
Can't exec convert through exec() on windows
Posted: 2011-12-09T16:22:51-07:00
by fcaserio
<?
echo $cmd = "cd C:\\PROGRA~1\\ImageMagick-6.7.3-Q16 & convert -colorspace RGB -size 120x120 -resize 120x120 \"D:\htdocs\\tempfile.pdf\" \"D:\\htdocs\\temp\\file.jpg\"";
exec($cmd);
?>
When executing through PHP nothing happens.
If I copy $cmd to DOS it works.
The same script works on other server.
Any ideas?
Re: Can't exec convert through exec() on windows
Posted: 2011-12-09T17:55:25-07:00
by fmw42
I am no expert on PHP on windows but it may want forward slashes rather than backslashes.
Some PHP configurations will not allow exec(). Check with your PHP setup or ISP.
Re: Can't exec convert through exec() on windows
Posted: 2011-12-09T19:53:46-07:00
by fcaserio
Image paths can use forward slashes, but the convert.exe path must be declared with backslashes.
The application I'm managing was runing without errors, but there was a contingence that Windows had to be reinstalled. I'm restoring all the application funcionalities, but the convert command called by exec function is not working.
I don't understand if there is a permission issue that appeared after reinstalling Windows or what is the problem that is causing the convert command be ignored by the exec function.
Really any help is appreciated!!
Re: Can't exec convert through exec() on windows
Posted: 2011-12-09T20:02:45-07:00
by fmw42
Does your PHP have the right path to IM?
Have you checked your php config.
http://yourwebaddress/phpinfo.php
Re: Can't exec convert through exec() on windows
Posted: 2011-12-09T20:19:29-07:00
by fcaserio
Why should my PHP have the right to use IM? Since I'm calling convert from the command line, is there any permission that dhould be set?
Re: Can't exec convert through exec() on windows
Posted: 2011-12-09T20:27:36-07:00
by fcaserio
Sorry, I misunderstood your comment.
My PHP script has the correct path to convert.
If I copy the command line generated by PHP and copy it to DOS it works fine.
Just through PHP convert is not being executed.
Re: Can't exec convert through exec() on windows
Posted: 2011-12-09T20:38:42-07:00
by fcaserio
I was checking phpinfo as you suggested.
The Imagemagick path appeared under Apache environment -> Path on previous instalation, but is not appearing now.
I'm not sure from where Apache environment -> path is being read...