[eluser]sawatdee[/eluser]
I use a web host, so I am limited to what they have installed, GD only. I am using the following code to calculate my new width and height, and it works great when I don't use the CI image library. As far as I know, both algorithms use GD. I haven't examined the CI source code closely, but if others have had the same problem and GD works when I don't use the library, then I wonder if there could be a small bug in the library somewhere. Wish I had time to look into it.
Code:
$widthRatio = $widthMax / $imageData ['image_width'];
$heightRatio = $heightMax / $imageData ['image_height'];
$widthNew = $widthMax;
$heightNew = $heightMax;
if ($widthRatio <= $heightRatio)
{
$widthNew = $imageData ['image_width'] * $widthRatio;
$heightNew = $imageData ['image_height'] * $widthRatio;
}
else
{
$widthNew = $imageData ['image_width'] * $heightRatio;
$heightNew = $imageData ['image_height'] * $heightRatio;
}