Jip Posted June 29, 2007 Share Posted June 29, 2007 I have installed ImageMagick and GhostScript (Windows/IIS) and IM is working from the command line (specifically the convert command) so now I need to get it working in php. To that end I have the following code: <?php system("c:Program Files\ImageMagick-6.3.4-Q16\convert.exe c:\Inetpub\wwwroot\exp\graphics\imgMagick\test_file.ai c:\Inetpub\wwwroot\exp\graphics\imgMagick\AIC.png",$retvar); echo $retvar; // Now you can check the $retvar for errors ?> c:Program Files\ImageMagick-6.3.4-Q16\convert.exe - the root folder for IM, location of convert.exe c:\Inetpub\wwwroot\exp\graphics\imgMagick\test_file.ai - the location of the target image to use for conversion c:\Inetpub\wwwroot\exp\graphics\imgMagick\AIC.png - the location, name, and format for the converted image Using the above code, it does not create a new png image. Before I set the permissions for the Internet Guest Account user to "read & execute" for the cmd.exe file located at C:\WINDOWS\system32, $retvar was echoing a value of -1. Once I set the permissions on C:\WINDOWS\system32\cmd.exe, $retvar is echoing a value of 1. In either case, the new graphic is NOT generated. Is there something wrong with my syntax? Any feedback will be greatly appreciated. Link to comment https://forums.phpfreaks.com/topic/57785-imagemagick-and-executing-external-programs-in-php/ Share on other sites More sharing options...
per1os Posted June 29, 2007 Share Posted June 29, 2007 I think you have to escape the \ system("c:\\Program Files\\ImageMagick-6.3.4-Q16\\convert.exe c:\\Inetpub\\wwwroot\\exp\\graphics\\imgMagick\\test_file.ai c:\\Inetpub\\wwwroot\\exp\\graphics\\imgMagick\AIC.png",$retvar); Like seen above. Link to comment https://forums.phpfreaks.com/topic/57785-imagemagick-and-executing-external-programs-in-php/#findComment-286242 Share on other sites More sharing options...
Jip Posted July 5, 2007 Author Share Posted July 5, 2007 Frost110 - thanks for the feedback. Unfortunately, this did not work. I also tried moving the convert.exe to the root of C: since C:\Program Files contains a space. However, this did not work either. Here is my updated code that looks for a return code to determine the outcome: <?php exec("C:\convert.exe c:\Inetpub\wwwroot\exp\graphics\imgMagick\test_file.ai c:\Inetpub\wwwroot\exp\graphics\imgMagick\bb.png", $response, $return_code); echo "<pre>"; // check status code. if successful if ($return_code == 0) { // process array line by line foreach ($response as $line) { echo "$line \n"; } } else { echo "Error in command"; // if unsuccessful display error } echo "</pre>"; ?> Not sure what to try next so any additional feedback w/b appreciated. Link to comment https://forums.phpfreaks.com/topic/57785-imagemagick-and-executing-external-programs-in-php/#findComment-290363 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.