1
0
mirror of https://github.com/Intervention/image.git synced 2025-09-01 18:02:45 +02:00

Merge pull request #887 from vlakoff/resize

Avoid 0px result dimensions when resizing images with extreme ratios
This commit is contained in:
Oliver Vogel
2019-05-31 11:51:43 +02:00
committed by GitHub

View File

@@ -154,7 +154,7 @@ class Size
}
if ($constraint->isFixed(Constraint::ASPECTRATIO)) {
$h = intval(round($this->width / $constraint->getSize()->getRatio()));
$h = max(1, intval(round($this->width / $constraint->getSize()->getRatio())));
if ($constraint->isFixed(Constraint::UPSIZE)) {
$this->height = ($h > $max_height) ? $max_height : $h;
@@ -190,7 +190,7 @@ class Size
}
if ($constraint->isFixed(Constraint::ASPECTRATIO)) {
$w = intval(round($this->height * $constraint->getSize()->getRatio()));
$w = max(1, intval(round($this->height * $constraint->getSize()->getRatio())));
if ($constraint->isFixed(Constraint::UPSIZE)) {
$this->width = ($w > $max_width) ? $max_width : $w;