-1

I am getting problem with ghost working in windows server 2003 (32 Bit).

In phpinfo page, it shows installed. Also, i am able to generate .png file using Command line interface, but when i am trying to generate a .png file using PHP script it is not working.

 $SavedPath = "C:\\Inetpub\\vhosts\\mysite\\httpdocs\\testlib\\images\\";

  $pdf_file = "C:\\Inetpub\\vhosts\\mysite\\httpdocs\\testlib\\test.pdf";

  $cmd =  "gs -sDEVICE=jpeg -dJPEGQ=100 -dGraphicsAlphaBits=4 -dTextAlphaBits=4 -dDOINTERPOLATE -sOutputFile=".$SavedPath."_%d.jpg -dSAFER -dBATCH -dNOPAUSE -r72x72 ".$pdf_file;

  Ghostscript is installed on C:\gs\bin\gsdll32.dll.
  And exe file is located on C:\gs\bin\gswin32c.exe.

Please advise me, should i have to change in environment variable in windows? I have also tried conver command instead for gs, but no luck.

Carrie Kendall
  • 11,124
  • 5
  • 61
  • 81
Milap
  • 6,915
  • 8
  • 26
  • 46

1 Answers1

2

Try using $output = shell_exec($cmd); echo "<pre>$output</pre>"; - and see if an error is printed out.

As @Dan mentioned, you could also use exec($cmd, $output); and then print_r($output);

Dan's method might prove to yield more info since shell_exec returns null if an error occurs.

Update

The issue could be permissions as @Dan mentioned.

Regarding Permissions:

Found another post on SO about this: this post acutally references another site: http://www.myfaqbase.com/q0000843.html

Community
  • 1
  • 1
Kennith Nichol
  • 338
  • 1
  • 9
  • @knichil, i have tried shell_exec($cmd) as well as exec($cmd, $output). But still no luck with it. I checked with permissions, but there is no issue with permission also. Also print_r($output) giving no errors as well. – Milap Feb 11 '12 at 03:48
  • I am sorry @Milap, but I am fresh out of ideas. No errors, no permission problems, it is a most interesting problem. – Kennith Nichol Feb 14 '12 at 00:19
  • @knichol , thanks for your response but i have asked to my Hosting provider that, why PHP User don't have permission to execute any command on server? And they told me that PHP user has all access and interesting part is that , i am able to use other commands like exec("whoami") and it works fine but have problem in only Ghost script.. – Milap Feb 14 '12 at 05:46
  • Hello @knichol. My problem solved. Issue was with the user permissions on windows server for PHP user, i gave all access to PHP user using super admin and its worked for me.. Thanks for your time.. – Milap Feb 15 '12 at 09:38
  • Hi @Milap. It's funny how permissions issues always seem to cause unexpected problems. I am happy to hear that you solved the problem! – Kennith Nichol Feb 18 '12 at 00:35
  • @knichol Yah , permission issues always cause so much headache but finally it is solved, cheers.. Thanks man.. – Milap Feb 18 '12 at 03:55