note 27974 deleted from function.imagecopyresized by cece
| From: | cece@php.net | Date: | Sat, 16 Aug 2003 20:08:10 +0000 |
| Subject: | note 27974 deleted from function.imagecopyresized by cece | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-54449@lists.php.net to get a copy of this message | ||
Note Submitter: webmaster(at site)returntothepit dot com
----
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);