You are here

protected function ImagemagickArgumentsImageEffect::getDimensions in Image Effects 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageEffect/ImagemagickArgumentsImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\ImagemagickArgumentsImageEffect::getDimensions()
  2. 8 src/Plugin/ImageEffect/ImagemagickArgumentsImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\ImagemagickArgumentsImageEffect::getDimensions()

Calculate resulting image dimensions.

Parameters

int $source_width: Source image width.

int $source_height: Source image height.

Return value

array Associative array.

  • width: Integer with the derivative image width.
  • height: Integer with the derivative image height.
2 calls to ImagemagickArgumentsImageEffect::getDimensions()
ImagemagickArgumentsImageEffect::applyEffect in src/Plugin/ImageEffect/ImagemagickArgumentsImageEffect.php
Applies an image effect to the image object.
ImagemagickArgumentsImageEffect::transformDimensions in src/Plugin/ImageEffect/ImagemagickArgumentsImageEffect.php
Determines the dimensions of the styled image.

File

src/Plugin/ImageEffect/ImagemagickArgumentsImageEffect.php, line 145

Class

ImagemagickArgumentsImageEffect
Class ImagemagickArgumentsImageEffect.

Namespace

Drupal\image_effects\Plugin\ImageEffect

Code

protected function getDimensions($source_width, $source_height) {
  $dimensions = [];
  switch ($this->configuration['dimensions_method']) {
    case 'strip':

      // Strip dimensions of the result.
      $dimensions['width'] = $dimensions['height'] = NULL;
      break;
    case 'keep':

      // Keep original image dimensions.
      $dimensions['width'] = $source_width;
      $dimensions['height'] = $source_height;
      break;
    case 'value':

      // Manually specified dimensions.
      $dimensions['width'] = ImageUtility::percentFilter($this->configuration['width'], $source_width);
      $dimensions['height'] = ImageUtility::percentFilter($this->configuration['height'], $source_height);
      break;
  }
  return $dimensions;
}