function Resize::execute
Same name in other branches
- 9 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Resize::execute()
- 8.9.x core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Resize::execute()
- 10 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Resize.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Resize::execute()
Overrides ImageToolkitOperationBase::execute
1 method overrides Resize::execute()
- Scale::execute in core/
modules/ system/ src/ Plugin/ ImageToolkit/ Operation/ gd/ Scale.php - Performs the actual manipulation on the image.
File
-
core/
modules/ system/ src/ Plugin/ ImageToolkit/ Operation/ gd/ Resize.php, line 56
Class
- Resize
- Defines GD2 resize operation.
Namespace
Drupal\system\Plugin\ImageToolkit\Operation\gdCode
protected function execute(array $arguments = []) {
// Create a new image of the required dimensions, and copy and resize
// the original image on it with resampling.
$original_image = $this->getToolkit()
->getImage();
$data = [
'width' => $arguments['width'],
'height' => $arguments['height'],
'extension' => image_type_to_extension($this->getToolkit()
->getType(), FALSE),
'transparent_color' => $this->getToolkit()
->getTransparentColor(),
'is_temp' => TRUE,
];
if ($this->getToolkit()
->apply('create_new', $data)) {
if (imagecopyresampled($this->getToolkit()
->getImage(), $original_image, 0, 0, 0, 0, $arguments['width'], $arguments['height'], imagesx($original_image), imagesy($original_image))) {
return TRUE;
}
// In case of failure, restore the original image.
$this->getToolkit()
->setImage($original_image);
}
return FALSE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.