Someone may wonder that when we have Photoshop, why do we bother to create thumbnail images using Php? Well answer is quite easy, whenever you upload photos to your web site to attract your readers or someone, every time you will have to cut or crop or do something on your photos by manually. Is not it annoying?
Once you completed your few lines of code you will no longer suffer from editing photos.
Here is your source code.
Result :
Good luck
Once you completed your few lines of code you will no longer suffer from editing photos.
Here is your source code.
// Path of photo.$img_name="Gear2nd.sized.jpg";//In this case thumbnail image size will be twice smaller than its original.//based on original photo's size this size can be changed.$thm_size=2;// Typeheader('Content-type: image/jpeg');// Generating Thumbnail's size.list($width, $height)=getimagesize($img_name);$new_width=$width / $thm_size;$new_height =$height / $thm_size;// Generating thumbnail image$thm_img=imagecreatetruecolor($new_width, $new_height);$img=imagecreatefromjpeg($img_name);imagecopyresampled($thm_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height);// show off the thumbnailimagejpeg($thm_img, null,100);
Result :
Good luck
No comments:
Post a Comment