class Desaturate

Same name in other branches
  1. 9 core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate
  2. 8.9.x core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate
  3. 11.x core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php \Drupal\system\Plugin\ImageToolkit\Operation\gd\Desaturate

Defines GD2 Desaturate operation.

Hierarchy

Expanded class hierarchy of Desaturate

6 string references to 'Desaturate'
ImageEffectsTest::testDesaturateEffect in core/modules/image/tests/src/Kernel/ImageEffectsTest.php
Tests the 'image_desaturate' effect.
ImageTest::testDesaturate in core/tests/Drupal/Tests/Core/Image/ImageTest.php
Tests \Drupal\Core\Image\Image::desaturate().
ToolkitGdTest::providerTestImageFiles in core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
Data provider for ::testManipulations().
ToolkitGdTest::testManipulations in core/tests/Drupal/KernelTests/Core/Image/ToolkitGdTest.php
Tests height, width and color for the corners for the final images.
ToolkitTestTrait::assertToolkitOperationsCalled in core/tests/Drupal/Tests/Traits/Core/Image/ToolkitTestTrait.php
Assert that all of the specified image toolkit operations were called once.

... See full list

File

core/modules/system/src/Plugin/ImageToolkit/Operation/gd/Desaturate.php, line 11

Namespace

Drupal\system\Plugin\ImageToolkit\Operation\gd
View 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()
            ->getImage(), 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 Overrides ImageToolkitOperationInterface::apply
ImageToolkitOperationBase::prepareArguments protected function Checks for required arguments and adds optional argument defaults.
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.