Php user Posted July 20, 2007 Share Posted July 20, 2007 I need to resize the image in correct proportion to obtain the quality thumbnails, Please any one help me regarding this, Thanks in advance, User Quote Link to comment Share on other sites More sharing options...
chigley Posted July 20, 2007 Share Posted July 20, 2007 Can't you just divide the width and height by the same number? eg. To halve the size output it at (width / 2) x (height / 2) Seems easiest way to me.. Quote Link to comment Share on other sites More sharing options...
jaikar Posted July 20, 2007 Share Posted July 20, 2007 below is the code i used.. hope it will help.. function r ($image,$size,$dir,$ext_name="", $tocopy=0, $todir='') { $path_to_file = $dir; $image=$path_to_file.$image; if(file_exists($image)) { list($imgWidth,$imgHeight,$type,$imgAttr)=getimagesize($image); $tempno = max($imgWidth, $imgHeight); if($tempno > ($size - 1)){ $proportion = ($size / $tempno); $width = round($imgWidth * $proportion); $height = round($imgHeight * $proportion); } else { $width = $imgWidth; $height = $imgHeight; } $ext=getFileExtension($image); $ext=".".$ext; $image=ereg_replace($ext, "", $image); resize($width,$height,"$image"."$ext_name"); } } Quote Link to comment Share on other sites More sharing options...
socratesone Posted July 20, 2007 Share Posted July 20, 2007 Found a good tutorial for making thumbnails: http://icant.co.uk/articles/phpthumbnails/ 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.