2017-10-18 08:46:57 +02:00
|
|
|
<?php
|
|
|
|
function always_decimal_format($x) { return (intval($x) == $x ? number_format($x, 1, '.', '') : $x ); }
|
|
|
|
function gcd($a,$b) {
|
|
|
|
$a = abs($a); $b = abs($b);
|
|
|
|
if( $a < $b) list($b,$a) = Array($a,$b);
|
|
|
|
if( $b == 0) return $a;
|
|
|
|
$r = $a % $b;
|
|
|
|
while($r > 0) {
|
|
|
|
$a = $b;
|
|
|
|
$b = $r;
|
|
|
|
$r = $a % $b;
|
|
|
|
}
|
|
|
|
return $b;
|
|
|
|
}
|
|
|
|
function simplify($num,$den) {
|
|
|
|
$g = gcd($num,$den);
|
|
|
|
return Array($num/$g,$den/$g);
|
|
|
|
}
|
|
|
|
function get_title($width, $height) {
|
|
|
|
$title = $width . "x" . $height;
|
|
|
|
$ratio = simplify($width, $height);
|
2017-10-19 08:18:40 +02:00
|
|
|
if (!($ratio[0] == 16 && $ratio[1] == 9)) {
|
2017-10-18 08:46:57 +02:00
|
|
|
if ($ratio[0] == 64 && $ratio[1] == 27) {
|
|
|
|
// 64:27 is the true ratio, but 21:9 is the common approximation
|
|
|
|
$title = $title . " (21:9)";
|
2017-10-19 02:08:19 +02:00
|
|
|
} else if ($ratio[0] == 43 && $ratio[1] == 18) {
|
|
|
|
// 43:18 is the true ratio for 3440x1440, but 21:9 is the common approximation
|
|
|
|
$title = $title . " (21:9)";
|
2017-12-18 04:55:58 +01:00
|
|
|
} else if ($ratio[0] == 7 && $ratio[1] == 3) {
|
|
|
|
// 2100x900 and 4200x1800 are actual 21:9 (21*100 and 9*100) but for some reason it calculates to 7:3?
|
|
|
|
$title = $title . " (21:9)";
|
2018-10-24 08:18:49 +02:00
|
|
|
} else if ($ratio[0] == 853 && $ratio[1] == 360) {
|
|
|
|
// 21:9 720p calculates to 853:360
|
|
|
|
$title = $title . " (21:9)";
|
2017-10-18 08:46:57 +02:00
|
|
|
} else if ($ratio[0] == 8 && $ratio[1] == 5) {
|
|
|
|
// common sense
|
|
|
|
$title = $title . " (16:10)";
|
2017-10-19 07:32:42 +02:00
|
|
|
} else if ($ratio[0] == 427 && $ratio[1] == 240) {
|
|
|
|
// common sense
|
|
|
|
return $title;
|
2017-10-24 03:53:09 +02:00
|
|
|
} else if ($ratio[0] == 683 && $ratio[1] == 384) {
|
|
|
|
// common sense
|
|
|
|
return $title;
|
2018-10-25 04:02:43 +02:00
|
|
|
} else if ($ratio[0] == 71 && $ratio[1] == 40) {
|
|
|
|
// common sense
|
|
|
|
return $title;
|
2017-10-18 08:46:57 +02:00
|
|
|
} else {
|
|
|
|
$title = $title . " (" . $ratio[0] .":". $ratio[1] . ")";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $title;
|
|
|
|
}
|
|
|
|
?>
|