Using Imagemagick from PHP on Apache Mac Server

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
frodfigu
Posts: 6
Joined: 2010-11-12T15:43:38-07:00
Authentication code: 8675308

Using Imagemagick from PHP on Apache Mac Server

Post by frodfigu »

Hi for all.

I have a problem to execute a simple line of code to convert an image

Code: Select all

<?php
	echo exec("/opt/local/bin/convert foto.jpg -thumbnail 50x50 output.jpg");
?>
I have this path from executing this following code on terminal

Code: Select all

type convert
On my terminal this code works fine and I haven´t to include the path like this:

Code: Select all

convert foto.jpg -thumbnail 50x50 output.jpg
I have an Apache Server installed on my mac, and php works fine on other projects... And this code runs ok on php

Code: Select all

<?php
	echo system("/opt/local/bin/convert -version");
	?>
So anyone can help me? I want to configure php to use Imagemagick commands and without the entire path.

Thank you!!
frodfigu
Posts: 6
Joined: 2010-11-12T15:43:38-07:00
Authentication code: 8675308

Re: Using Imagemagick from PHP on Apache Mac Server

Post by frodfigu »

I can see this error on my Apache Log:

Code: Select all

identify: unable to open image `foto.jpg': Permission denied @ error/blob.c/OpenBlob/2709
Please anyone can help me?

:( :( :(
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using Imagemagick from PHP on Apache Mac Server

Post by fmw42 »

Does PHP have permissions for the directory holding that image?

You may need to set the PHP environment PATH to include the path to IM /opt/local/bin. It probably does not look there by default and is probably looking in /usr/local/bin or /usr/bin. Check your phpinfo.php file to see where it is looking for IM.

Is this your server? If not, ask your ISP.
Post Reply