extrovertive Posted August 19, 2006 Share Posted August 19, 2006 Ok, I know how to have people upload a picture.Now, when they upload a picture, it will generate two versions - a porpotional thumbnail and the normal size pic they uploaded.The old way I'm doing is, let the people upload the pic (regardless of the size). When I output the pic - I have it be a fixed size of "width=90" and "height=90". Some pics look distorted that way. Now, I want to take the height and width attributes off the img tag and show the thumbnail generaed image instead and when they click the thumbnail, it will show the normal size pic.How can I do this? Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 19, 2006 Share Posted August 19, 2006 Here's a start to getting thumbnails created at upload timehttp://fundisom.com/phparadise/php/image_handling/image_upload_and_resize Quote Link to comment Share on other sites More sharing options...
extrovertive Posted August 19, 2006 Author Share Posted August 19, 2006 Thanks for the link.Only problem is, it works for JPEG only right?Plus, when I tried it on my localhost, it says the function imagecreatetruecolor was not found.So, I decided to use a cheap trick I found athttp://www.sitepoint.com/article/image-resizing-phpAll it does is resize the image by dimension and not by the filesize. Quote Link to comment Share on other sites More sharing options...
Yesideez Posted August 19, 2006 Share Posted August 19, 2006 That's similar to what I plan to use for my site:[code]<?php function imageresize($max_width,$max_height,$image) { $dimensions=getimagesize($image); $width_percentage=round($max_width/$dimensions[0]); $height_percentage=round($max_height/$dimensions[1]); if ($width_percentage<=$height_percentage) { $new_width=$width_percentage*$dimensions[0]; $new_height=$width_percentage*$dimensions[1]; } else { $new_width=$height_percentage*$dimensions[0]; $new_height=$height_percentage*$dimensions[1]; } $new_image=array($new_width,$new_height); return $new_image; }?>[/code] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.