From 4a4fc12f491b5618529dc5f3a259b7a9a0bfa79b Mon Sep 17 00:00:00 2001 From: vlakoff Date: Sun, 9 Sep 2018 04:53:33 +0200 Subject: [PATCH] Avoid 0px result dimensions when resizing images with extreme ratios --- src/Intervention/Image/Size.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Intervention/Image/Size.php b/src/Intervention/Image/Size.php index 667784ca..b01376a8 100644 --- a/src/Intervention/Image/Size.php +++ b/src/Intervention/Image/Size.php @@ -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;