diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Crop.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Crop.php index 15c21f7..7a87081 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Crop.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Crop.php @@ -43,7 +43,7 @@ public function prepare(ImageInterface $image, array &$arguments) { parent::prepare($image, $arguments); // Preserve aspect. - $aspect = $image->getHeight() / $image->getWidth(); + $aspect = $this->toolkit->getHeight($image) / $this->toolkit->getWidth($image); $arguments['height'] = empty($arguments['height']) ? $arguments['width'] * $aspect : $arguments['height']; $arguments['width'] = empty($arguments['width']) ? $arguments['height'] / $aspect : $arguments['width']; @@ -59,16 +59,14 @@ public function prepare(ImageInterface $image, array &$arguments) { public function apply(ImageInterface $image, array $arguments = array()) { $res = $this->toolkit->createTmp($image->getType(), $arguments['width'], $arguments['height']); - if (!imagecopyresampled($res, $image->getToolkit()->getResource(), 0, 0, $arguments['x'], $arguments['y'], $arguments['width'], $arguments['height'], $arguments['width'], $arguments['height'])) { + if (!imagecopyresampled($res, $this->toolkit->getResource(), 0, 0, $arguments['x'], $arguments['y'], $arguments['width'], $arguments['height'], $arguments['width'], $arguments['height'])) { return FALSE; } // Destroy the original image and return the modified image. - imagedestroy($image->getToolkit()->getResource()); - $image->getToolkit()->setResource($res); - $image - ->setWidth($arguments['width']) - ->setHeight($arguments['height']); + imagedestroy($this->toolkit->getResource()); + $this->toolkit->setResource($res); + return TRUE; } diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Desaturate.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Desaturate.php index 4a51a6e..908946f 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Desaturate.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Desaturate.php @@ -33,7 +33,7 @@ public function apply(ImageInterface $image, array $arguments = array()) { return FALSE; } - return imagefilter($image->getToolkit()->getResource(), IMG_FILTER_GRAYSCALE); + return imagefilter($this->toolkit->getResource(), IMG_FILTER_GRAYSCALE); } } diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Resize.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Resize.php index c7ea101..f7e25b6 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Resize.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Resize.php @@ -52,16 +52,14 @@ public function apply(ImageInterface $image, array $arguments = array()) { $res = $this->toolkit->createTmp($image->getType(), $arguments['width'], $arguments['height']); - if (!imagecopyresampled($res, $image->getToolkit()->getResource(), 0, 0, 0, 0, $arguments['width'], $arguments['height'], $image->getWidth(), $image->getHeight())) { + if (!imagecopyresampled($res, $this->toolkit->getResource(), 0, 0, 0, 0, $arguments['width'], $arguments['height'], $this->toolkit->getWidth($image), $this->toolkit->getHeight($image))) { return FALSE; } - imagedestroy($image->getToolkit()->getResource()); + imagedestroy($this->toolkit->getResource()); // Update image object. - $image->getToolkit()->setResource($res); - $image - ->setWidth($arguments['width']) - ->setHeight($arguments['height']); + $this->toolkit->setResource($res); + return TRUE; } diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Rotate.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Rotate.php index af238e2..50ecfa2 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Rotate.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Rotate.php @@ -48,39 +48,36 @@ public function apply(ImageInterface $image, array $arguments = array()) { for ($i = 16; $i >= 0; $i -= 8) { $rgb[] = (($arguments['background'] >> $i) & 0xFF); } - $arguments['background'] = imagecolorallocatealpha($image->getToolkit()->getResource(), $rgb[0], $rgb[1], $rgb[2], 0); + $arguments['background'] = imagecolorallocatealpha($this->toolkit->getResource(), $rgb[0], $rgb[1], $rgb[2], 0); } // Set background color as transparent if $arguments['background'] is NULL. else { // Get the current transparent color. - $arguments['background'] = imagecolortransparent($image->getToolkit()->getResource()); + $arguments['background'] = imagecolortransparent($this->toolkit->getResource()); // If no transparent colors, use white. if ($arguments['background'] == 0) { - $arguments['background'] = imagecolorallocatealpha($image->getToolkit()->getResource(), 255, 255, 255, 0); + $arguments['background'] = imagecolorallocatealpha($this->toolkit->getResource(), 255, 255, 255, 0); } } // Images are assigned a new color palette when rotating, removing any // transparency flags. For GIF images, keep a record of the transparent color. if ($image->getType() == IMAGETYPE_GIF) { - $transparent_index = imagecolortransparent($image->getToolkit()->getResource()); + $transparent_index = imagecolortransparent($this->toolkit->getResource()); if ($transparent_index != 0) { - $transparent_gif_color = imagecolorsforindex($image->getToolkit()->getResource(), $transparent_index); + $transparent_gif_color = imagecolorsforindex($this->toolkit->getResource(), $transparent_index); } } - $image->getToolkit()->setResource(imagerotate($image->getToolkit()->getResource(), 360 - $arguments['degrees'], $arguments['background'])); + $this->toolkit->setResource(imagerotate($this->toolkit->getResource(), 360 - $arguments['degrees'], $arguments['background'])); // GIFs need to reassign the transparent color after performing the rotate. if (isset($transparent_gif_color)) { - $arguments['background'] = imagecolorexactalpha($image->getToolkit()->getResource(), $transparent_gif_color['red'], $transparent_gif_color['green'], $transparent_gif_color['blue'], $transparent_gif_color['alpha']); - imagecolortransparent($image->getToolkit()->getResource(), $arguments['background']); + $arguments['background'] = imagecolorexactalpha($this->toolkit->getResource(), $transparent_gif_color['red'], $transparent_gif_color['green'], $transparent_gif_color['blue'], $transparent_gif_color['alpha']); + imagecolortransparent($this->toolkit->getResource(), $arguments['background']); } - $image - ->setWidth(imagesx($image->getToolkit()->getResource())) - ->setHeight(imagesy($image->getToolkit()->getResource())); return TRUE; } diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Scale.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Scale.php index e189e34..26dd310 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Scale.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/Scale.php @@ -57,7 +57,7 @@ public function prepare(ImageInterface $image, array &$arguments) { // target dimensions is missing, that is the one that is calculated. If both // are specified then the dimension calculated is the one that would not be // calculated to be bigger than its target. - $scale = $image->getHeight() / $image->getWidth(); + $scale = $this->toolkit->getHeight($image) / $this->toolkit->getWidth($image); if (($width && !$height) || ($width && $height && $scale < $height / $width)) { $height = (int) round($width * $scale); } @@ -69,7 +69,7 @@ public function prepare(ImageInterface $image, array &$arguments) { parent::prepare($image, $arguments); // Don't upscale if the option isn't enabled. - if (!$arguments['upscale'] && ($width >= $image->getWidth() || $height >= $image->getHeight())) { + if (!$arguments['upscale'] && ($width >= $this->toolkit->getWidth($image) || $height >= $this->toolkit->getHeight($image))) { return FALSE; } } diff --git a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php index 977ec34..da04b14 100644 --- a/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php +++ b/core/modules/system/lib/Drupal/system/Plugin/ImageToolkit/Operation/gd/ScaleAndCrop.php @@ -36,8 +36,8 @@ class ScaleAndCrop extends ImageToolkitOperationBase { public function prepare(ImageInterface $image, array &$arguments) { parent::prepare($image, $arguments); - $width = $image->getWidth(); - $height = $image->getHeight(); + $width = $this->toolkit->getWidth($image); + $height = $this->toolkit->getHeight($image); $scale = max($arguments['width'] / $width, $arguments['height'] / $height);