You are here

trait SetGifTransparentColorTrait in Image Effects 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageToolkit/Operation/SetGifTransparentColorTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\SetGifTransparentColorTrait
  2. 8.2 src/Plugin/ImageToolkit/Operation/SetGifTransparentColorTrait.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\SetGifTransparentColorTrait

Base trait for set_gif_transparent_color image operations.

Hierarchy

2 files declare their use of SetGifTransparentColorTrait
SetGifTransparentColor.php in src/Plugin/ImageToolkit/Operation/gd/SetGifTransparentColor.php
SetGifTransparentColor.php in src/Plugin/ImageToolkit/Operation/imagemagick/SetGifTransparentColor.php

File

src/Plugin/ImageToolkit/Operation/SetGifTransparentColorTrait.php, line 10

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation
View source
trait SetGifTransparentColorTrait {

  /**
   * {@inheritdoc}
   */
  protected function arguments() {
    return [
      'transparent_color' => [
        'description' => 'The RGB hex color for GIF transparency',
        'required' => FALSE,
        'default' => '#ffffff',
      ],
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function validateArguments(array $arguments) {

    // Assure transparent color is a valid hex string.
    if ($arguments['transparent_color'] && !Color::validateHex($arguments['transparent_color'])) {
      $transparent_color = $arguments['transparent_color'];
      throw new \InvalidArgumentException("Invalid transparent color ({$transparent_color}) specified for the image 'set_gif_transparent_color' operation");
    }
    return $arguments;
  }

}

Members