note 44805 deleted from function.imagecopyresized by aidan
| From: | aidan@php.net | Date: | Mon, 04 Oct 2004 08:52:39 +0000 |
| Subject: | note 44805 deleted from function.imagecopyresized by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77896@lists.php.net to get a copy of this message | ||
Note Submitter: tilgiz at mail dot ru
----
This is better...
gd2 is used
<?
function resize_jpg($img,$w,$h){
$imagedata = getimagesize($img);
if ($w && ($imagedata[0] < $imagedata[1])) {
$w = ($h / $imagedata[1]) * $imagedata[0];
} else {
$h = ($w / $imagedata[0]) * $imagedata[1];
}
$im2 = ImageCreateTrueColor($w,$h);
$image = ImageCreateFromJpeg($img);
imagecopyResampled ($im2, $image, 0, 0, 0, 0, $w, $h, $imagedata[0], $imagedata[1]);
ImageJpeg($im2, $img, 100);
}
resize_jpg("picture.jpg",200,200);
?>