I can\'t believe I can\'t find the formula for this. I am using a PHP script called SLIR to resize images. The script asks to specify an aspect ratio for cropping. I\'d like
to get the aspect ratio just simplify the width and height like a fraction for example:
1024 4
---- = ---
768 3
the php code:
function gcd($a, $b)
{
if ($a == 0 || $b == 0)
return abs( max(abs($a), abs($b)) );
$r = $a % $b;
return ($r != 0) ?
gcd($b, $r) :
abs($b);
}
$gcd=gcd(1024,768);
echo "Aspect ratio = ". (1024/$gcd) . ":" . (768/$gcd);