protected function SetCanvasImageEffect::getDimensions in Image Effects 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/ImageEffect/SetCanvasImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\SetCanvasImageEffect::getDimensions()
- 8 src/Plugin/ImageEffect/SetCanvasImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\SetCanvasImageEffect::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 SetCanvasImageEffect::getDimensions()
- SetCanvasImageEffect::applyEffect in src/
Plugin/ ImageEffect/ SetCanvasImageEffect.php - Applies an image effect to the image object.
- SetCanvasImageEffect::transformDimensions in src/
Plugin/ ImageEffect/ SetCanvasImageEffect.php - Determines the dimensions of the styled image.
File
- src/
Plugin/ ImageEffect/ SetCanvasImageEffect.php, line 263
Class
- SetCanvasImageEffect
- Class SetCanvasImageEffect.
Namespace
Drupal\image_effects\Plugin\ImageEffectCode
protected function getDimensions($source_width, $source_height) {
$dimensions = [];
if ($this->configuration['canvas_size'] === 'exact') {
// Exact size.
$tmp_width = $this->configuration['exact']['width'] ?: $source_width;
$tmp_height = $this->configuration['exact']['height'] ?: $source_height;
$dimensions['width'] = ImageUtility::percentFilter($tmp_width, $source_width);
$dimensions['height'] = ImageUtility::percentFilter($tmp_height, $source_height);
}
else {
// Relative size.
$dimensions['width'] = $source_width + $this->configuration['relative']['left'] + $this->configuration['relative']['right'];
$dimensions['height'] = $source_height + $this->configuration['relative']['top'] + $this->configuration['relative']['bottom'];
}
return $dimensions;
}