note 27974 added to function.imagecopyresized
| From: | webmaster at rack1 dot php dot net | Date: | Sat, 28 Dec 2002 00:18:42 +0000 |
| Subject: | note 27974 added to function.imagecopyresized | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41369@lists.php.net to get a copy of this message | ||
ok, I worked a bunch of code from a bunch of different places together to make this, true color jpeg
AND resizes.
enjoy
ps: I'm sure you can figure out the email from above if need be.
$picture_location = "./picture.jpg";
$picture_save = "./picturethumb2.jpg";
$size=78; // size in pixel u want the picture to come out
$im_size = GetImageSize ( $picture_location);
$imageWidth = $im_size[0];
$imageHeight = $im_size[1];
// - or with GD 2+ -
// do all your color allocations here
//$font_color_black = ImageColorAllocate( $im, 0,0,0);
$im2 = ImageCreateFromJPEG($picture_location);
if ($imageWidth>=$imageHeight)
{
$width=$size;
$height = ($width/$imageWidth)*$imageHeight;
}
else
{
$height=$size;
$width = ($height/$imageHeight)*$imageWidth;
}
$im = imageCreateTrueColor( $width, $height );
ImageCopyResized ($im,$im2, 0, 0, 0, 0, $width, $height, $imageWidth, $imageHeight);
Header("Content-type: image/jpeg");
Imagejpeg($im,'',100); //to print to screen
Imagejpeg($im,$picture_save,100);
ImageDestroy($im);
ImageDestroy ($im2);
--
http://www.php.net/manual/en/function.imagecopyresized.php
http://master.php.net/manage/user-notes.php?action=edit+27974
http://master.php.net/manage/user-notes.php?action=delete+27974
http://master.php.net/manage/user-notes.php?action=reject+27974