CONVERT.exe in PHP script doesn't work, but it's OK FROM cmd

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
stexcec

CONVERT.exe in PHP script doesn't work, but it's OK FROM cmd

Post by stexcec »

HI All, i'm new with ImageMagick and i'va a very strange problem.
i work on my Windows XP pro sp2 machine, with IIS and PHP 5.2.5

i've installed ghostscript, imagemagick static q16 version, and set the PATH variable correctly (i hope!).

From a command prompt, this command convert a .ps image into a .png image

Code: Select all

e:\wikimath\imagick\convert e:\wikimath\imagick\input.ps e:\wikimath\imagick\output.png
where "e:\wikimath\imagick" is my application path. All works very fine.

BUT...

if I put the command in a simple php page into my personal webserver, like this

Code: Select all

<?php
echo exec('e:\wikimath\imagick\convert e:\wikimath\imagick\input.ps e:\wikimath\imagick\output.png');
?> 
nothing happens, and i've have no error messages.

also, from a phpinfo() command , the system variable is:

Path: e:\wikimath\imagick;e:\wikimath\miktex\miktex\bin;D:\php\;C:\Program Files\PC Connectivity Solution\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\ATI Technologies\ATI Control Panel;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Program Files\Microsoft SQL Server\80\Tools\Binn\;D:\Program Files\Microsoft SQL Server\90\Tools\binn\;D:\Program Files\Microsoft SQL Server\90\DTS\Binn\;D:\Program Files\Microsoft SQL Server\90\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files\Microsoft Visual Studio 8\Common7\IDE\PrivateAssemblies\;C:\Program Files\Smart Projects\IsoBuster;C:\Program Files\ATI Technologies\ATI.ACE\Core-Static;d:\php\ext;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\IrfanView;E:\wikimath\gs\gs8.54\bin

i've also copied and renamed the ghostscript executable gswin32c.exe in gs.exe, and from a command prompt all the executables files run fine.

please, there is a solution on my problem?

regards, stefano
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: CONVERT.exe in PHP script doesn't work, but it's OK FROM cmd

Post by el_supremo »

I think the backslash character is an "escape" in PHP, so you would need to double it.

Code: Select all

<?php
echo exec('e:\\wikimath\\imagick\\convert e:\\wikimath\\imagick\\input.ps e:\\wikimath\\imagick\\output.png');
?>
Pete
stexcec

Re: CONVERT.exe in PHP script doesn't work, but it's OK FROM cmd

Post by stexcec »

thanks for your answer, but the problem relies on ghostscript.
a script like this:
<?php

$output = system('e:\\wikimath\\imagick\\convert e:\\wikimath\\imagick\\mini.jpg e:\\wikimath\\imagick\\mini.png');

print $output;

?>
works fine from my PHP page.

there is a way to know if convert.exe can reach ghostscript?

regards, stefano
Post Reply