Merge pull request #270 from drzax/gd

ENHANCEMENT: Before preforming an image resize, make sure it's actually required
This commit is contained in:
Sean Harvey 2012-03-26 01:19:32 -07:00
commit 2a853b1b5b

View File

@ -64,6 +64,11 @@ class GD extends Object {
$width = round($width); $width = round($width);
$height = round($height); $height = round($height);
// Check that a resize is actually necessary.
if ($width == $this->width && $height == $this->height) {
return $this;
}
$newGD = imagecreatetruecolor($width, $height); $newGD = imagecreatetruecolor($width, $height);
// Preserves transparency between images // Preserves transparency between images
@ -125,6 +130,11 @@ class GD extends Object {
$width = round($width); $width = round($width);
$height = round($height); $height = round($height);
// Check that a resize is actually necessary.
if ($width == $this->width && $height == $this->height) {
return $this;
}
if(!$width && !$height) user_error("No dimensions given", E_USER_ERROR); if(!$width && !$height) user_error("No dimensions given", E_USER_ERROR);
if(!$width) user_error("Width not given", E_USER_ERROR); if(!$width) user_error("Width not given", E_USER_ERROR);
if(!$height) user_error("Height not given", E_USER_ERROR); if(!$height) user_error("Height not given", E_USER_ERROR);
@ -299,6 +309,10 @@ class GD extends Object {
$width = round($width); $width = round($width);
$height = round($height); $height = round($height);
// Check that a resize is actually necessary.
if ($width == $this->width && $height == $this->height) {
return $this;
}
$newGD = imagecreatetruecolor($width, $height); $newGD = imagecreatetruecolor($width, $height);