/ Published in: PHP
URL: http://www.itwebinfo.com/forum/comments.php?DiscussionID=4&page=1#Item_0
Expand |
Embed | Plain Text
<? /*this can be used to resize image in jpeg format only which provive a good quality thumbnails*/ // This is the temporary file created by PHP $uploadedfile = $_FILES['simage']['tmp_name']; // Create an Image from it so we can do the resize $src = imagecreatefromjpeg($uploadedfile); // Capture the original size of the uploaded image $newwidth=300; //$newheight=($height/$width)*100; $newheight=200; $tmp=imagecreatetruecolor($newwidth,$newheight); // this line actually does the image resizing, copying from the original // image into the $tmp image imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height); // now write the resized image to disk. I have assumed that you want the // resized, uploaded image file to reside in the ./images subdirectory. $filename = $_FILES['simage']['name']; imagejpeg($tmp,$filename,100); imagedestroy($src); imagedestroy($tmp); ?>
You need to login to post a comment.
