View Single Post
  #4  
Old 03-05-2008, 10:19 AM
atholon is offline atholon
"ath-hole"

Join Date: Jan 2003
Location: Failville.
Posts: 11,357

Send a message via MSN to atholon
Darn! I could help you to but the code is at home!

You could something like this:
Code:
function image_resize($iImage, $allowedwidth, $allowedheight)
{
	   list($width, $height, $type, $attr) = getimagesize($iImage);

      if($width > $allowedwidth || $height > $allowedheight)
       {
         
          if ($width > $height)
          {
            $offset = $width / $allowedwidth ;
            if ($offset<=1)
            {
            $offset = $width - $allowed;
            $newimagewidth =$width - $offset;
            $newimageheight =$height - $offset;
            }
            else
            {
            $newimagewidth =$width / $offset;
            $newimageheight =$height / $offset;
           }            
    
          }
          elseif ($width < $height)
          {
             $offset = $height / $allowedwidth ;
            if ($offset<=1)
            {
            $offset = $height - $allowed;
            $newimagewidth =$width - $offset;
            $newimageheight =$height - $offset;
            }
            else
            {
            $newimagewidth =$width / $offset;
            $newimageheight =$height / $offset;
            }            
          }
}
PS I am not sure if that is the actual working code.
__________________

Last edited by atholon; 03-05-2008 at 10:44 AM.
Reply With Quote