Can't exec convert through exec() on windows

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
fcaserio
Posts: 26
Joined: 2007-03-19T15:22:12-07:00

Can't exec convert through exec() on windows

Post 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?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Can't exec convert through exec() on windows

Post 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.
fcaserio
Posts: 26
Joined: 2007-03-19T15:22:12-07:00

Re: Can't exec convert through exec() on windows

Post 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!!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Can't exec convert through exec() on windows

Post by fmw42 »

Does your PHP have the right path to IM?

Have you checked your php config. http://yourwebaddress/phpinfo.php
fcaserio
Posts: 26
Joined: 2007-03-19T15:22:12-07:00

Re: Can't exec convert through exec() on windows

Post 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?
fcaserio
Posts: 26
Joined: 2007-03-19T15:22:12-07:00

Re: Can't exec convert through exec() on windows

Post 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.
fcaserio
Posts: 26
Joined: 2007-03-19T15:22:12-07:00

Re: Can't exec convert through exec() on windows

Post 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...
Post Reply