Page 1 of 1
Newbie question:how to get started in php
Posted: 2010-09-05T16:58:39-07:00
by drmarie
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?
Re: Newbie question:how to get started in php
Posted: 2010-09-05T17:45:04-07:00
by drmarie
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\">";
?>
Re: Newbie question:how to get started in php
Posted: 2010-09-05T18:08:41-07:00
by fmw42
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]);
?>