From 3880479abb5b377fa1a0b3030702f96042b91a08 Mon Sep 17 00:00:00 2001 From: Simon Elvery Date: Tue, 30 Aug 2011 11:49:44 +1000 Subject: [PATCH] Bug fix: Ensure image sizes are rounded. The imagecopyresampled function should be provided with integers, not floats. --- filesystem/GD.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/filesystem/GD.php b/filesystem/GD.php index 36a0b4acb..b79572499 100755 --- a/filesystem/GD.php +++ b/filesystem/GD.php @@ -81,16 +81,16 @@ class GD extends Object { $srcY = 0; $srcHeight = $this->height; - $srcWidth = $this->height * $destAR; - $srcX = ($this->width - $srcWidth) / 2; + $srcWidth = round( $this->height * $destAR ); + $srcX = round( ($this->width - $srcWidth) / 2 ); // Destination shorter than the source } else { $srcX = 0; $srcWidth = $this->width; - $srcHeight = $this->width / $destAR; - $srcY = ($this->height - $srcHeight) / 2; + $srcHeight = round( $this->width / $destAR ); + $srcY = round( ($this->height - $srcHeight) / 2 ); } imagecopyresampled($newGD, $this->gd, 0,0, $srcX, $srcY, $width, $height, $srcWidth, $srcHeight); @@ -320,16 +320,16 @@ class GD extends Object { $destY = 0; $destHeight = $height; - $destWidth = $height * $srcAR; - $destX = ($width - $destWidth) / 2; + $destWidth = round( $height * $srcAR ); + $destX = round( ($width - $destWidth) / 2 ); // Destination shorter than the source } else { $destX = 0; $destWidth = $width; - $destHeight = $width / $srcAR; - $destY = ($height - $destHeight) / 2; + $destHeight = round( $width / $srcAR ); + $destY = round( ($height - $destHeight) / 2 ); } imagecopyresampled($newGD, $this->gd, $destX, $destY, 0, 0, $destWidth, $destHeight, $this->width, $this->height);