note 30187 deleted from function.imagecopyresized by aidan
| From: | aidan@php.net | Date: | Mon, 04 Oct 2004 08:32:55 +0000 |
| Subject: | note 30187 deleted from function.imagecopyresized by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77894@lists.php.net to get a copy of this message | ||
Note Submitter: quark_k at yahoo dot com
----
If you're looking for a straight forward function which resizes and replaces a jpg, you can use
this simple function.
<?
// resize function
function resize_jpg($img,$w,$h){
$thumb = imagecreate ($w, $h);
$image = ImageCreateFromJpeg($img);
$imagedata = getimagesize($img);
imagecopyresized ($thumb, $image, 0, 0, 0, 0, $w, $h, $imagedata[0], $imagedata[1]);
imagejpeg($thumb, $img);
}
// call resize function resize_jpg(image name, new width, new height)
resize_jpg("somepic.jpg",100,100);
?>
Cheers
Giv