...

View Full Version : Imagemagick issues



samroberts
01-13-2004, 08:29 AM
Hello,

I've used Imagemagick on several sites - I've occasionally run into problems, but with a little tweaking, it's fixed.

On the site I'm currently working on, I'm having no such luck. Images get uploaded without issue, but the thumbnail creation fails. I'm posting a portion of the relevant code here:

-----BEGIN-----

$LARGE_PATH="/home/lbier/public_html/lambda/large/";
$THUMB_PATH="/home/lbier/public_html/lambda/thumbs/thumb_";

copy($image_file[0],$LARGE_PATH.$image_file_name[0]);

$quality="100";
$res="150x100";
@exec("which convert", $my_convert_path);

$imagePath=$LARGE_PATH.$image_file_name[0];
$resizedFile=$THUMB_PATH.$image_file_name[0];

$make_magick = system("convert -resize ".$res." -quality ".$quality." \"".$imagePath."\" \"".$resizedFile."\"",$retval);

-----END-----

Any ideas on what I'm doing wrong?

firepages
01-13-2004, 04:19 PM
you are putting the path of `convert` into $my_convert_path (which may well be an array so check it ) but not actually using it

system("convert -resize ".$res." -quality ".$quality." \"".$imagePath."\" \"".$resizedFile."\"",$retval);

e.g use $my_convert_path (or $my_convert_path[0] ) instead.

I have had occaision to use `mogrify` or one of the other IM commands before when 'convert' pointed to a totally different application but that would be unusual (on *NIX)

samroberts
01-13-2004, 06:04 PM
I've made the appropriate change, but no thumb is being created.

I am now using:

$make_magick = system($my_convert_path[0]." -resize ".$res." -quality ".$quality." \"".$imagePath."\" \"".$resizedFile."\"",$retval);

However, when I print out this statement, $my_convert_path[0] is empty. The output for:

echo($my_convert_path[0]." -resize ".$res." -quality ".$quality." \"".$imagePath."\" \"".$resizedFile."\"");

is:

-resize 150x100 -quality 100 "/home/lbier/public_html/lambda/large/cliff.jpg" "/home/lbier/public_html/lambda/thumbs/thumb_cliff.jpg"

firepages
01-14-2004, 12:20 AM
;) check the path first then...


@exec("which convert", $my_convert_path);

if( is_array( $my_convert_path ) ){
print_r( $my_convert_path ) ;
}else{
echo $my_convert_path.'<br />';
}

samroberts
01-14-2004, 02:40 AM
Okay, I came up with a slightly kludgey solution to this. My $my_convert_path is an empty array for some reason.

I looked up some earlier code that I used on another server and dropped it in:

@exec("/usr/local/bin/mogrify -scale ".$res." -quality ".$quality." \"".$resizedFile."\"");

I now copy the large file to the thumb folder and use only one path in the command line (the one contained in $resizedFile).

This isn't an ideal solution, but it'll do for the moment.

Thanks for your help - much appreciated.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum