Replaced the doubled code in for getScalingDimension with Images::getScalingDimensions($width, $height,$max)
This commit is contained in:
parent
59268c600c
commit
88a7dd1afb
1 changed files with 2 additions and 39 deletions
|
@ -289,45 +289,8 @@ class Image
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($width > $max && $height > $max) {
|
$scale = Images::getScalingDimensions($width, $height,$max);
|
||||||
// very tall image (greater than 16:9)
|
return $this->scale($scale['width'], $scale['height']);
|
||||||
// constrain the width - let the height float.
|
|
||||||
|
|
||||||
if ((($height * 9) / 16) > $width) {
|
|
||||||
$dest_width = $max;
|
|
||||||
$dest_height = intval(($height * $max) / $width);
|
|
||||||
} elseif ($width > $height) {
|
|
||||||
// else constrain both dimensions
|
|
||||||
$dest_width = $max;
|
|
||||||
$dest_height = intval(($height * $max) / $width);
|
|
||||||
} else {
|
|
||||||
$dest_width = intval(($width * $max) / $height);
|
|
||||||
$dest_height = $max;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ($width > $max) {
|
|
||||||
$dest_width = $max;
|
|
||||||
$dest_height = intval(($height * $max) / $width);
|
|
||||||
} else {
|
|
||||||
if ($height > $max) {
|
|
||||||
// very tall image (greater than 16:9)
|
|
||||||
// but width is OK - don't do anything
|
|
||||||
|
|
||||||
if ((($height * 9) / 16) > $width) {
|
|
||||||
$dest_width = $width;
|
|
||||||
$dest_height = $height;
|
|
||||||
} else {
|
|
||||||
$dest_width = intval(($width * $max) / $height);
|
|
||||||
$dest_height = $max;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$dest_width = $width;
|
|
||||||
$dest_height = $height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->scale($dest_width, $dest_height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue