Welcome Guest, Not a member yet? Register   Sign In
Resize and maintain the golden ratio (3:5)?
#6

[eluser]TheFuzzy0ne[/eluser]
Sorry, I was wrong. You'd need to crop by the smallest dimension. It's 5:32AM and my brain is not working any more.

Code:
function getCropDimensions($width, $height)
{
    if ($height < width) // Height is master dim
    {
        $width = ($height / 3) * 5;
    }
    else // Otherwise width is master dim
    {
        $height = ($width / 5) * 3;
    }
    return array(
            'height' => $height,
            'width' => $width
        );
}
The above code is untested, but should work for you.


Messages In This Thread
Resize and maintain the golden ratio (3:5)? - by El Forum - 02-21-2009, 10:30 PM
Resize and maintain the golden ratio (3:5)? - by El Forum - 02-21-2009, 10:48 PM
Resize and maintain the golden ratio (3:5)? - by El Forum - 02-21-2009, 11:07 PM
Resize and maintain the golden ratio (3:5)? - by El Forum - 02-21-2009, 11:19 PM
Resize and maintain the golden ratio (3:5)? - by El Forum - 02-21-2009, 11:25 PM
Resize and maintain the golden ratio (3:5)? - by El Forum - 02-21-2009, 11:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB