mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #270 from drzax/gd
ENHANCEMENT: Before preforming an image resize, make sure it's actually required
This commit is contained in:
commit
2a853b1b5b
@ -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);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user