class SetGifTransparentColor in Image Effects 8
Same name in this branch
- 8 src/Plugin/ImageToolkit/Operation/gd/SetGifTransparentColor.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\SetGifTransparentColor
- 8 src/Plugin/ImageToolkit/Operation/imagemagick/SetGifTransparentColor.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\SetGifTransparentColor
Same name and namespace in other branches
- 8.3 src/Plugin/ImageToolkit/Operation/imagemagick/SetGifTransparentColor.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\SetGifTransparentColor
- 8.2 src/Plugin/ImageToolkit/Operation/imagemagick/SetGifTransparentColor.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\SetGifTransparentColor
Defines ImageMagick set_gif_transparent_color image operation.
Plugin annotation
@ImageToolkitOperation(
id = "image_effects_imagemagick_set_gif_transparent_color",
toolkit = "imagemagick",
operation = "set_gif_transparent_color",
label = @Translation("Set the image transparent color"),
description = @Translation("Set the image transparent color for GIF images.")
)
Hierarchy
- class \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\SetGifTransparentColor extends \Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\ImagemagickImageToolkitOperationBase uses ImagemagickOperationTrait, SetGifTransparentColorTrait
Expanded class hierarchy of SetGifTransparentColor
File
- src/
Plugin/ ImageToolkit/ Operation/ imagemagick/ SetGifTransparentColor.php, line 19
Namespace
Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagickView source
class SetGifTransparentColor extends ImagemagickImageToolkitOperationBase {
use ImagemagickOperationTrait;
use SetGifTransparentColorTrait;
/**
* {@inheritdoc}
*/
protected function execute(array $arguments) {
$format = $this
->getToolkit()
->getDestinationFormat() ?: $this
->getToolkit()
->getSourceFormat();
$mime_type = $this
->getFormatMapper()
->getMimeTypeFromFormat($format);
if ($mime_type === 'image/gif' && $arguments['transparent_color']) {
$index = $this
->getToolkit()
->findArgument('-alpha off -transparent-color');
if ($index !== FALSE) {
$this
->getToolkit()
->removeArgument($index);
}
$this
->getToolkit()
->addArgument('-alpha off -transparent-color ' . $this
->getToolkit()
->escapeShellArg($arguments['transparent_color']) . ' -transparent ' . $this
->getToolkit()
->escapeShellArg($arguments['transparent_color']));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ImagemagickOperationTrait:: |
protected | property | The format mapper service. | |
ImagemagickOperationTrait:: |
protected | function | Returns the format mapper service. | |
SetGifTransparentColor:: |
protected | function | ||
SetGifTransparentColorTrait:: |
protected | function | ||
SetGifTransparentColorTrait:: |
protected | function |