[eluser]KeyStroke[/eluser]
Thank you so much Colin. You've pushed me in the right direction.
Now that I'm over converting aspect ratio, I've figured out the rest. Building on your code:
Code:
$ratio_x = 240;
$ratio_y = 145;
list($image_x, $image_y) = getimagesize($image_filepath);
$new_image_y = $image_y;
$new_image_x = $image_x;
if ($ratio_x > $ratio_y)
{
$new_image_y = ($image_x * $ratio_y) / $ratio_x;
}
else
{
$new_image_x = ($image_y * $ratio_x) / $ratio_y;
}
$crop_x = ($image_x - $new_image_x) / 2;
$crop_y = ($image_y - $new_image_y) / 2;
And it works like a charm!
And regarding your warning, I don't think the new dimensions could be larger than the original. (Correct me if I'm wrong)