Find the path to ImageMagick on your server

The path will be the same to all the other commands like composite


<?php
echo "<pre>";
system("type convert"); 
echo 
"</pre>";
?>

Output:

convert is /usr/local/bin/convert

Note: System displays the results to the screen where exec will not.




Alternative method

<?php
echo "<pre>";
system('which convert',$path); print_r($path); 
echo 
"</pre>";
?>

Output:

/usr/local/bin/convert 0

'which' is a program that is generally on ALL UNIX machines, which searches the users command 'PATH' to find the given program.
'type' is a shell built in that does the same thing but just looks up the result from the saved results of the shells own search when it started up; it also returns builtins, alias and functions of that name that may be defined in the shell.
'locate' is a simular command that is available on more modern UNIX machines (typically Linux and MacOX) which just finds files (not commands) containing that name. It can also be useful for the above, but it will not always work on all OSs. It will find the 'convert' when it is NOT on the system supplied PATH to the PHP script.




Portable method

To make the code more portable you can use this to get the path to convert from the server and automaticaly put it into your code.


<?php
// In my case $HTTP_ENV_VARS['PATH'] = bin:usr/bin
$env_vars explode':'$HTTP_ENV_VARS['PATH']);
// Combine the required part from $HTTP_ENV_VARS['PATH'] and convert for your path.
$env_path $env_vars[1]."/convert";
// Now $env_path = usr/bin/convert

// Usage:
exec("$env_path image.jpg -resize 100x100 output.jpg");
?>



Nothing displayed?

This is something I have found after a new install - for some reason none of the above give the path; where Imagemagick is installed is anyones guess.
I suggest you contact your hosts who should be able to tell you or if you have access to the server running # which convert should give the path. You could also try variations of /usr/local/bin/convert or /usr/bin/convert etc.