Aspect ratio for images
This commit is contained in:
parent
a2a404f1da
commit
348ae010bc
@ -223,9 +223,33 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Highest common factor
|
||||||
|
function hcf($a, $b){
|
||||||
|
$gcd = 1;
|
||||||
|
if ($a>$b) {
|
||||||
|
$a = $a+$b;
|
||||||
|
$b = $a-$b;
|
||||||
|
$a = $a-$b;
|
||||||
|
}
|
||||||
|
if ($b==(round($b/$a))*$a)
|
||||||
|
$gcd=$a;
|
||||||
|
else {
|
||||||
|
for($i=round($a/2);$i;$i--) {
|
||||||
|
if ($a == round($a/$i)*$i && $b == round($b/$i)*$i) {
|
||||||
|
$gcd = $i;
|
||||||
|
$i = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $gcd;
|
||||||
|
}
|
||||||
|
|
||||||
function fraction($numerator, $denominator, $sep) {
|
function fraction($numerator, $denominator, $sep) {
|
||||||
$fraction = Array($numerator, $denominator);
|
$gcf = hcf($numerator, $denominator);
|
||||||
return "{$fraction[0]}{$sep}{$fraction[1]}";
|
$numerator = $numerator / $gcf;
|
||||||
|
$denominator = $denominator / $gcf;
|
||||||
|
|
||||||
|
return "{$numerator}{$sep}{$denominator}";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user