Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #51 from drzax/fix-gd

BUGFIX: Ensure image sizes are rounded.
  • Loading branch information...
commit c35c48b76834c54b9c198afc98941c6707e9979f 2 parents f0933e3 + 3880479
@wilr wilr authored
Showing with 8 additions and 8 deletions.
  1. +8 −8 filesystem/GD.php
View
16 filesystem/GD.php
@@ -81,16 +81,16 @@ function croppedResize($width, $height) {
$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 @@ function paddedResize($width, $height, $backgroundColor = "FFFFFF") {
$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);
Please sign in to comment.
Something went wrong with that request. Please try again.