class Desaturate
Same name in other branches
- 9 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate
- 10 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate
- 11.x core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate
Defines GD2 Desaturate operation.
Plugin annotation
@ImageToolkitOperation(
id = "gd_desaturate",
toolkit = "gd",
operation = "desaturate",
label = @Translation("Desaturate"),
description = @Translation("Converts an image to grayscale.")
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
- class \Drupal\Core\ImageToolkit\ImageToolkitOperationBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\ImageToolkit\ImageToolkitOperationInterface
- class \Drupal\system\Plugin\ImageToolkit\Operation\gd\GDImageToolkitOperationBase extends \Drupal\Core\ImageToolkit\ImageToolkitOperationBase
- class \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate extends \Drupal\system\Plugin\ImageToolkit\Operation\gd\GDImageToolkitOperationBase
- class \Drupal\system\Plugin\ImageToolkit\Operation\gd\GDImageToolkitOperationBase extends \Drupal\Core\ImageToolkit\ImageToolkitOperationBase
- class \Drupal\Core\ImageToolkit\ImageToolkitOperationBase extends \Drupal\Core\Plugin\PluginBase implements \Drupal\Core\ImageToolkit\ImageToolkitOperationInterface
- class \Drupal\Core\Plugin\PluginBase extends \Drupal\Component\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait
Expanded class hierarchy of Desaturate
7 string references to 'Desaturate'
- ImageEffectsTest::testDesaturateEffect in core/
modules/ image/ tests/ src/ Functional/ ImageEffectsTest.php - Test the image_desaturate_effect() function.
- ImageTest::testDesaturate in core/
tests/ Drupal/ Tests/ Core/ Image/ ImageTest.php - Tests \Drupal\Core\Image\Image::desaturate().
- ToolkitGdTest::testManipulations in core/
tests/ Drupal/ KernelTests/ Core/ Image/ ToolkitGdTest.php - Since PHP can't visually check that our images have been manipulated properly, build a list of expected color values for each of the corners and the expected height and widths for the final images.
- ToolkitTestBase::assertToolkitOperationsCalled in core/
modules/ system/ src/ Tests/ Image/ ToolkitTestBase.php - Assert that all of the specified image toolkit operations were called exactly once once, other values result in failure.
- ToolkitTestBase::assertToolkitOperationsCalled in core/
tests/ Drupal/ FunctionalTests/ Image/ ToolkitTestBase.php - Assert that all of the specified image toolkit operations were called exactly once once, other values result in failure.
File
-
core/
modules/ system/ src/ Plugin/ ImageToolkit/ Operation/ gd/ Desaturate.php, line 16
Namespace
Drupal\system\Plugin\ImageToolkit\Operation\gdView source
class Desaturate extends GDImageToolkitOperationBase {
/**
* {@inheritdoc}
*/
protected function arguments() {
// This operation does not use any parameters.
return [];
}
/**
* {@inheritdoc}
*/
protected function execute(array $arguments) {
// PHP installations using non-bundled GD do not have imagefilter.
if (!function_exists('imagefilter')) {
$this->logger
->notice("The image '@file' could not be desaturated because the imagefilter() function is not available in this PHP installation.", [
'@file' => $this->getToolkit()
->getSource(),
]);
return FALSE;
}
return imagefilter($this->getToolkit()
->getResource(), IMG_FILTER_GRAYSCALE);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Desaturate::arguments | protected | function | Returns the definition of the operation arguments. | Overrides ImageToolkitOperationBase::arguments | |
Desaturate::execute | protected | function | Performs the actual manipulation on the image. | Overrides ImageToolkitOperationBase::execute | |
GDImageToolkitOperationBase::getToolkit | protected | function | The correctly typed image toolkit for GD operations. | Overrides ImageToolkitOperationBase::getToolkit | |
ImageToolkitOperationBase::$logger | protected | property | A logger instance. | ||
ImageToolkitOperationBase::$toolkit | protected | property | The image toolkit. | ||
ImageToolkitOperationBase::apply | final public | function | Applies a toolkit specific operation to an image. | Overrides ImageToolkitOperationInterface::apply | |
ImageToolkitOperationBase::prepareArguments | protected | function | Checks if required arguments are passed in and adds defaults for non passed in optional arguments. |
||
ImageToolkitOperationBase::validateArguments | protected | function | Validates the arguments. | 6 | |
ImageToolkitOperationBase::__construct | public | function | Constructs an image toolkit operation plugin. | ||
PluginInspectionInterface::getPluginDefinition | public | function | Gets the definition of the plugin implementation. | 6 | |
PluginInspectionInterface::getPluginId | public | function | Gets the plugin_id of the plugin instance. | 2 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.