php passthru/exec command on Windows Apache

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
phy9pas

php passthru/exec command on Windows Apache

Post by phy9pas »

Hello,

I've been using IM on my unix servers fro some time, and recently I've had to use a WAMP type setup for developing locally nad I'm having trouble getting IM to work.

I've installed the Windows version of the binary and It works fine if I call it thoguh the command prompt.

Something like

Code: Select all

convert.exe "C:\path\to\myfile\source.jpg" "C:\path\to\myfile\destination.jpg"
I can't get it to work with a passthru (or exec) command in PHP.

I know it is finding the exe becasue if I call

Code: Select all

'C:\\Program Files (x86)\\ImageMagick-6.6.5-Q16\\convert.exe'
It returns all of the details IM spits out by detault about the version and available commands.

But if I try and pass in files, it seems to do nothing

Code: Select all

var $im = 'C:\\Program Files (x86)\\ImageMagick-6.6.5-Q16\\convert.exe';
$root = "C:\\Program Files (x86)\\Zend\\Apache2\\htdocs\\mysite\\httpdocs\\uploads";
$cmd = $im." '{$root}\\Source.jpg' '{$root}\\Dest.jpg'";
$result = passthru($cmd);
echo $result;
I've tried using forward slashes, single slashes,
I've tried setting root to 'uploads', './'

I've tried renaming convert.exe to IMconvert.exe

I feel like I've tried almost everything.

If anyone has any hints on how I should be referencing my image files I'd really appreciate it. Should they be relative to the convert.exe? Or to the script calling them or the site root?

Thanks in advance.

Pete
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: php passthru/exec command on Windows Apache

Post by Bonzo »

Windows needs " not '

I use XAMPP and use the same commands as I would on the server except ( ) do not need escaping and the " not ' Also you do not need the full path to convert.

Code: Select all

$cmd = source.jpg
exec ( " convert $cmd Dest.jpg ");
Should work if the php file and input files are in the same folder - assuming you have started Apache :)
Post Reply