diff --git a/core/lib/Drupal/Core/Image/Image.php b/core/lib/Drupal/Core/Image/Image.php index 62bf5ab..f7a5cd7 100644 --- a/core/lib/Drupal/Core/Image/Image.php +++ b/core/lib/Drupal/Core/Image/Image.php @@ -270,30 +270,30 @@ protected function processInfo() { * image toolkit. * * This is a temporary solution to keep patches reviewable. The __call() - * method will be replaced in https://drupal.org/node/2073759 with a new + * method will be replaced in https://drupal.org/node/2110499 with a new * interface method ImageInterface::apply(). An image operation will be * performed as in the next example: * @code * $image = new Image($path, $toolkit); * $image->apply('scale', array('width' => 50, 'height' => 100)); * @endcode - * Also in https://drupal.org/node/2073759 operation arguments sent to toolkit + * Also in https://drupal.org/node/2110499 operation arguments sent to toolkit * will be moved to a keyed array, unifying the interface of toolkit * operations. * - * @todo Drop this in https://drupal.org/node/2073759 in favor of new apply(). + * @todo Drop this in https://drupal.org/node/2110499 in favor of new apply(). */ public function __call($method, $arguments) { // @todo Temporary to avoid that legacy GD setResource(), getResource(), // hasResource() methods moved to GD toolkit in #2103621 get invoked // from this class anyway through the magic __call. Will be removed - // through https://drupal.org/node/2073759, when call_user_func_array() + // through https://drupal.org/node/2110499, when call_user_func_array() // will be replaced by $this->toolkit->apply($name, $this, $arguments). if (in_array($method, array('setResource', 'getResource', 'hasResource'))) { throw new \BadMethodCallException(); } if (is_callable(array($this->toolkit, $method))) { - // @todo In https://drupal.org/node/2073759, call_user_func_array() will + // @todo In https://drupal.org/node/2110499, call_user_func_array() will // be replaced by $this->toolkit->apply($name, $this, $arguments). array_unshift($arguments, $this); return call_user_func_array(array($this->toolkit, $method), $arguments); diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php index 78246b4..1bd1d36 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/GDToolkit.php @@ -22,20 +22,20 @@ class GDToolkit extends ImageToolkitBase { /** - * An image file handle. + * A GD image resource. * * @var resource */ protected $resource; /** - * Sets the image file resource. + * Sets the GD image resource. * * @param resource $resource - * The image file handle. + * The GD image resource. * * @return self - * Returns this image file. + * Returns this toolkit object. */ public function setResource($resource) { $this->resource = $resource; @@ -43,10 +43,10 @@ public function setResource($resource) { } /** - * Retrieves the image file resource. + * Retrieves the GD image resource. * * @return resource - * The image file handle. + * The GD image resource. */ public function getResource() { return $this->resource; @@ -94,8 +94,7 @@ public function resize(ImageInterface $image, $width, $height) { imagedestroy($this->getResource()); // Update image object. - $this - ->setResource($res); + $this->setResource($res); $image ->setWidth($width) ->setHeight($height); @@ -174,8 +173,7 @@ public function crop(ImageInterface $image, $x, $y, $width, $height) { // Destroy the original image and return the modified image. imagedestroy($this->getResource()); - $this - ->setResource($res); + $this->setResource($res); $image ->setWidth($width) ->setHeight($height); @@ -236,7 +234,7 @@ public function scaleAndCrop(ImageInterface $image, $width, $height) { * * @param string $source * String specifying the path of the image file. - * @param string $details + * @param array $details * An array of image details. * * @return bool @@ -245,16 +243,16 @@ public function scaleAndCrop(ImageInterface $image, $width, $height) { protected function load($source, array $details) { $function = 'imagecreatefrom' . image_type_to_extension($details['type'], FALSE); if (function_exists($function) && $resource = $function($source)) { - $this->resource = $resource; + $this->setResource($resource); if (!imageistruecolor($resource)) { // Convert indexed images to true color, so that filters work // correctly and don't result in unnecessary dither. $new_image = $this->createTmp($details['type'], $details['width'], $details['height']); imagecopy($new_image, $resource, 0, 0, 0, 0, $details['width'], $details['height']); imagedestroy($resource); - $this->resource = $new_image; + $this->setResource($new_image); } - return (bool) $this->resource; + return (bool) $this->getResource(); } return FALSE; @@ -306,7 +304,7 @@ public function getInfo(ImageInterface $image) { $details = FALSE; $data = getimagesize($image->getSource()); - if (isset($data) && is_array($data)) { + if (isset($data) && is_array($data) && in_array($data[2], $this->supportedTypes())) { $details = array( 'width' => $data[0], 'height' => $data[1], @@ -324,7 +322,7 @@ public function getInfo(ImageInterface $image) { /** * Creates a truecolor image preserving transparency from a provided image. * - * @param string $type + * @param int $type * An image type represented by a PHP IMAGETYPE_* constant (e.g. * IMAGETYPE_JPEG, IMAGETYPE_PNG, etc.). * @param int $width diff --git a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php index 754231c..d85d813 100644 --- a/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php +++ b/core/modules/system/tests/modules/image_test/lib/Drupal/image_test/Plugin/ImageToolkit/TestToolkit.php @@ -74,7 +74,7 @@ public function getInfo(ImageInterface $image) { * * @param string $source * String specifying the path of the image file. - * @param string $details + * @param array $details * An array of image details. * * @return bool