Mercurial > hg > isophonics-drupal-site
diff core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/modules/image/src/Plugin/ImageEffect/DesaturateImageEffect.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,30 @@ +<?php + +namespace Drupal\image\Plugin\ImageEffect; + +use Drupal\Core\Image\ImageInterface; +use Drupal\image\ImageEffectBase; + +/** + * Desaturates (grayscale) an image resource. + * + * @ImageEffect( + * id = "image_desaturate", + * label = @Translation("Desaturate"), + * description = @Translation("Desaturate converts an image to grayscale.") + * ) + */ +class DesaturateImageEffect extends ImageEffectBase { + + /** + * {@inheritdoc} + */ + public function applyEffect(ImageInterface $image) { + if (!$image->desaturate()) { + $this->logger->error('Image desaturate failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', ['%toolkit' => $image->getToolkitId(), '%path' => $image->getSource(), '%mimetype' => $image->getMimeType(), '%dimensions' => $image->getWidth() . 'x' . $image->getHeight()]); + return FALSE; + } + return TRUE; + } + +}