psili |
01-07-2006 12:55 PM |
I'm not sure what you mean by "blurry / shitty", but I've used ImageMagick for a number of projects and the thumbs seem to turn out file.
What I first did is figure out if the image is landscape or portrait, then resize the image. After I resize it, I then crop it to a thumbnail.
I apologize for the random PHP code below, but it's what I've been using for ImageMagick with PHP to batch images, for example:
Code:
//-- original image
list($width,$height,$type,$attr) = getimagesize($curLgFile);
//-- thumbnail sizes
$mdW = '285'; // medium width
$mdH = '244'; // medium height
// figure out aspect
if($width > $height) // landscape
{
$width = $width * ($mdH / $height);
$height = $mdW;
}
else
{
$height = $height * ($mdW / $width);
$width = $mdW;
}
// convert the LARGE image into smaller in the MEDIUM directory
$bcmd = $imagemagick_path.'convert -resize '.ceil($width).'x'.ceil($height).' '
.$curLgFile.' '.$newMdFile;
system($bcmd,$output);
// then crop the medium to what we want
$bcmd = $imagemagick_path.'convert -crop '.$mdW.'x'.$mdH.'+0+0 '
.$newMdFile.' '.$newMdFile;
system($bcmd,$output);
I'm sure there's always a better way, but the above is just an example.
|