note 30187 added to function.imagecopyresized
| From: | quark_k at yahoo dot com | Date: | Mon, 10 Mar 2003 00:28:35 +0000 |
| Subject: | note 30187 added to function.imagecopyresized | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45050@lists.php.net to get a copy of this message | ||
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
--
http://www.php.net/manual/en/function.imagecopyresized.php
http://master.php.net/manage/user-notes.php?action=edit+30187
http://master.php.net/manage/user-notes.php?action=delete+30187
http://master.php.net/manage/user-notes.php?action=reject+30187