image calculation problem
| From: | Ryan A | Date: | Wed, 13 Apr 2005 21:37:21 +0000 |
| Subject: | image calculation problem | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-213035@lists.php.net to get a copy of this message | ||
Hi,
I copied this from the php site, but trying to modify it is driving me nuts
coz its not working.
Basically I am trying to make a thumb where the width is 87px...I dont care
what the height is,
heres the code:
function prop_thumb_height()
{
// The file
$filename = 'cat.jpg';
// Set a maximum height and width
$width = 87;
$height = 175;
// Content type
header('Content-type: image/jpeg');
// Get new dimensions
list($width_orig, $height_orig) = getimagesize($filename);
if ($width && ($width_orig < $height_orig)) {
$width = ($height / $height_orig) * $width_orig;
} else {
$height = ($width / $width_orig) * $height_orig;
}
// Resample
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($filename);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height,
$width_orig, $height_orig);
// Output
imagejpeg($image_p, 'ryan.jpg', 100);
}
Thanks,
Ryan
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.7 - Release Date: 4/12/2005