function Rotate::execute
Same name in other branches
- 9 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Rotate::execute()
- 8.9.x core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Rotate::execute()
- 10 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Rotate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Rotate::execute()
Overrides ImageToolkitOperationBase::execute
File
-
core/
modules/ system/ src/ Plugin/ ImageToolkit/ Operation/ gd/ Rotate.php, line 90
Class
- Rotate
- Defines GD2 rotate operation.
Namespace
Drupal\system\Plugin\ImageToolkit\Operation\gdCode
protected function execute(array $arguments) {
// PHP installations using non-bundled GD do not have imagerotate.
if (!function_exists('imagerotate')) {
$this->logger
->notice('The image %file could not be rotated because the imagerotate() function is not available in this PHP installation.', [
'%file' => $this->getToolkit()
->getSource(),
]);
return FALSE;
}
if ($new_image = imagerotate($this->getToolkit()
->getImage(), 360 - $arguments['degrees'], $arguments['background_idx'])) {
$this->getToolkit()
->setImage($new_image);
// GIFs need to reassign the transparent color after performing the
// rotate, but only do so, if the image already had transparency of its
// own, or the rotate added a transparent background.
if (!empty($arguments['gif_transparent_color'])) {
$transparent_idx = imagecolorexactalpha($this->getToolkit()
->getImage(), $arguments['gif_transparent_color']['red'], $arguments['gif_transparent_color']['green'], $arguments['gif_transparent_color']['blue'], $arguments['gif_transparent_color']['alpha']);
imagecolortransparent($this->getToolkit()
->getImage(), $transparent_idx);
}
return TRUE;
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.