From 8e241f0132742bbe32efda2fd85e674c2a8eddfa Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Mon, 20 Mar 2017 05:49:34 -0400 Subject: [PATCH] Add @horst-n fix for ImageSizerEngine rounding issue processwire/processwire-issues#191 --- wire/core/ImageSizerEngine.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wire/core/ImageSizerEngine.php b/wire/core/ImageSizerEngine.php index e283b151..4a324a6b 100755 --- a/wire/core/ImageSizerEngine.php +++ b/wire/core/ImageSizerEngine.php @@ -623,6 +623,10 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable $pWidth = $this->getProportionalWidth($targetHeight); } + // rounding issue fix via @horst-n for #191 + if($targetWidth == $originalTargetWidth && 1 + $targetWidth == $pWidth) $pWidth = $pWidth - 1; + if($targetHeight == $originalTargetHeight && 1 + $targetHeight == $pHeight) $pHeight = $pHeight - 1; + if(!$this->upscaling) { // we are going to shoot for something smaller than the target @@ -1083,7 +1087,7 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable $this->setFlip($value); break; case 'useUSM': - $this->setUseUsm($value); + $this->setUseUSM($value); break; default: @@ -1406,8 +1410,6 @@ abstract class ImageSizerEngine extends WireData implements Module, Configurable $this->fullHeight = $this->image['height']; if(0 == $this->finalWidth && 0 == $this->finalHeight) return false; - if(0 == $this->finalWidth) $this->finalWidth = ceil(($this->finalHeight / $this->fullHeight) * $this->fullWidth); - if(0 == $this->finalHeight) $this->finalHeight = ceil(($this->finalWidth / $this->fullWidth) * $this->fullHeight); if($this->scale !== 1.0) { // adjust for hidpi if($this->finalWidth) $this->finalWidth = ceil($this->finalWidth * $this->scale);