Click to See Complete Forum and Search --> : ImageMagick on localhost


oldhand
09-04-2002, 02:30 PM
Hi,

Does anyone know how to get Imagemagick working with PHP on localhost.

I have Windows XP pro with PHP4.2.2 on Apache.

I have installed ImageMagick and it works ok from the command prompt, but i cant seem to run the commands within PHP from the system() command?

Any suggestions are most welcome.

Thanks in advance.

t_chollet
09-23-2002, 01:46 AM
I wanted to do the same thing, and I was very disapointed that nobody has answered your post.

Anyway, I figured out why it did not work on my comp.

The problem is that to use convert or any program from ImageMagick , you have to specify the files you want to modify, right? But how to specify them under the system() or exec() php functions?

Mainly, you have to specify the absolute path to your files.

For example, i want to convert myPics.jpg (c:\apache\htdocs\pictures\myPics.jpg) to myPics.gif under Windows I'll call:

$make_Magick = exec("convert \"c:\apache\htdocs\pictures\myPics.jpg\" \"c:\apache\htdocs\pictures\myPics.gif\" ", $retval);


if (!($retval)) {
echo "Pics created ";
} else {
echo "error creating pics";
}

Note that even if your pictures are under the htdocs directory you have to specify the absolute path in windows (not the web-server one). I tried it and it didn't work for me.

Note also that you can to do something like that:

$current_dir = "c:\apache\htdocs\pictures\\";<-do not forget the double backslash!!
$current_file = "myPics";
$pics = $current_dir . $current_file;

$make_Magick = exec("convert " . $pics . ".jpg " . $pics. ".gif", $retval);


I also tried the follwoing, which obviously did not work:
$make_Magick1 = exec("cd \"c:\apache\htdocs\pictures", $retval1);

$make_Magick2 = exec("convert myPics.jpg myPics.gif " , $retval2);


Hope that help.

You can send me an e-mail at t_chollet@hotmail.com