Imagemagick script

Imagemagick script

Posted by: spidermite
Posted on: 2007-03-05 15:34:00

Hi, ive been driving myself crazy trying to get this imagemagick thumbnail script to work for almost 2 hrs. Everything seems to be in the right location with no errors but the script just runs through without converting, then deletes the old file (as it should). Im stuck.

$location='/usr/bin/convert';

$make_magick_th = system("$location -resize x60 -gravity North -crop 60x60+0+0 -quality 75 -strip $current_file $thumb_name", $retval_th);



Re: Imagemagick script

Posted by: silkrooster
Posted on: 2007-03-05 17:54:00

here's a sample convert script for php, maybe it'll help get you in the right direction.
Silk

<?php
$location='/usr/bin/convert';
$command='-thumbnail 150';
$name='glass.';
$extfrm='jpg';
$extto='png';
$output="{$name}{$extto}";
$convert=$location . ' ' .$command . ' ' . $name . $extfrm . ' ' . $name . $extto;
exec ($convert);
print "<img src=" . $output . ">";
?>

My website

Re: Imagemagick script

Posted by: spidermite
Posted on: 2007-03-06 03:04:00

Thanks for the script, i think i saw it already in the dreamhost wiki

http://wiki.dreamhost.com/index.php/Image_Magick

It seems to put together the exec() call like my script compiles its system()

The problem is that my script works on two other servers and i dont want to have to completely rewrite it for dreamhost (theres also more of it than ive posted).

Eveything else in the script seems to work, ive checked all the variables. Im just wondering whether i need to do a system() call differently in php-cgi or something. Any ideas?

Re: Imagemagick script

Posted by: spidermite
Posted on: 2007-03-07 05:03:00

Ok, ive changed the structure of my script:

$location='/usr/bin/convert';
$command = '-resize x60 -gravity North -crop 60x60 0 0 -quality 75 -strip';

$convert = $location . ' ' .$command . ' ' . $current_file . ' ' . $thumb_name;

exec($convert);

echo("<img src='".$current_file."'>");
$myFile = $current_file;
unlink($myFile);

But i still get nothing :(

Edited by spidermite on 03/07/07 05:04 AM (server time).

Re: Imagemagick script

Posted by: silkrooster
Posted on: 2007-03-07 16:32:00

If I am reading it right, it looks like the problem is in the echo statement. It looks like single quotes are surrounding the string. Remove the quotes or use double quotes.
Silk

My website

Re: Imagemagick script

Posted by: eci_mike
Posted on: 2007-03-08 16:57:00

If in doubt, go to ssh and try your imagemagick command there to see the response direct from the binary without php confusing the issue further. Have you checked the paths are correct for your input and output? Have you checked your error logs for output written there?

East Coast Interactive

Re: Imagemagick script

Posted by: spidermite
Posted on: 2007-03-15 07:46:00

I managed to solve that problem, it was my upload path. In my new dreamhost account the server path has a .com in it. I was splitting up the path by the . to find the extension so it all went wrong:)

Tags: imagemagickive beenusr binbin convertmagick