Skip to content

Commit

Permalink
add getAspectRatio
Browse files Browse the repository at this point in the history
  • Loading branch information
stepanenko3 committed Aug 31, 2022
1 parent 937d639 commit f808645
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@
use Illuminate\Support\Facades\Storage;
use Ramsey\Uuid\Uuid;


if (!function_exists('getAspectRatio')) {
function getAspectRatio(int $width, int $height)
{
// search for greatest common divisor
$greatestCommonDivisor = static function ($width, $height) use (&$greatestCommonDivisor) {
return ($width % $height) ? $greatestCommonDivisor($height, $width % $height) : $height;
};

$divisor = $greatestCommonDivisor($width, $height);

return $width / $divisor . ':' . $height / $divisor;
}
}

if (!function_exists('rglob')) {
function rglob($pattern)
{
Expand Down

0 comments on commit f808645

Please sign in to comment.