diff --git a/src/FocusPointImageExtension.php b/src/FocusPointImageExtension.php index a185e59..98195f5 100755 --- a/src/FocusPointImageExtension.php +++ b/src/FocusPointImageExtension.php @@ -234,16 +234,18 @@ public function FocusFill($width, $height, $upscale = true) { $width = intval($width); $height = intval($height); + $imgW = $this->owner->getWidth(); + $imgH = $this->owner->getHeight(); // Don't enlarge if (!$upscale) { - $widthRatio = $this->owner->width / $width; - $heightRatio = $this->owner->height / $height; + $widthRatio = $imgW / $width; + $heightRatio = $imgH / $height; if ($widthRatio < 1 && $widthRatio <= $heightRatio) { - $width = $this->owner->width; - $height = round($height * $widthRatio); + $width = $imgW; + $height = intval(round($height * $widthRatio)); } elseif ($heightRatio < 1) { - $height = $this->owner->height; - $width = round($width * $heightRatio); + $height = $imgH; + $width = intval(round($width * $heightRatio)); } } //Only resize if necessary