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?".
drmarie
Posts: 11 Joined: 2010-09-05T10:47:30-07:00
Authentication code: 8675308
Post
by drmarie » 2010-09-05T16:58:39-07:00
This is likely a dumb question, but I cannot figure out how to launch ImageMagick via a php script. My host tells me IM is available in /usr/bin
This is what I am trying:
Code: Select all
<?php
$cmd = '/usr/bin/convert "/images/rainbow.jpg" -colorspace Gray "/images/gray_rainbow.jpg"';
exec($cmd);
?>
But it does not create gray_rainbow.jpg
What am I doing wrong?
drmarie
Posts: 11 Joined: 2010-09-05T10:47:30-07:00
Authentication code: 8675308
Post
by drmarie » 2010-09-05T17:45:04-07:00
I think I figured it out...I'll post it in case it helps anyone else. This is the code I used:
Code: Select all
<?php
$test_directory = 'temp_images';
$command = "convert $test_directory/rainbow1.jpg -colorspace Gray $test_directory/rainbow3.jpg";
$test_image = system($command, $returnVal);
if ($returnVal > 1) echo "ERROR";
else echo "<img src=\"$test_directory/rainbow3.jpg\">";
?>
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2010-09-05T18:08:41-07:00
try this to verify if your IM convert is at /usr/local/bin or /usr/bin and to see what version of IM your ISP is using
<?php
exec("/usr/local/bin/convert -version",$out,$returnval);
print_r($out[0]);
?>
or
<?php
exec("which convert",$out,$returnval);
print_r($out[0]);
?>