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.