You are here

function _imagick_definecanvas_get_dimensions in Imagick 7

Helper function to calculate new width, height, x and y coordinates

Parameters

$image_info:

$exact_size:

$exact:

$relative:

Return value

array

2 calls to _imagick_definecanvas_get_dimensions()
image_imagick_definecanvas in effects/imagick.definecanvas.inc
Define the canvas of an image
imagick_definecanvas_dimensions in effects/imagick.definecanvas.inc

File

effects/imagick.definecanvas.inc, line 52

Code

function _imagick_definecanvas_get_dimensions($image_info, $exact_size, $exact, $relative) {
  if ($exact_size) {
    $width = imagick_percent_filter($exact['width'], $image_info['width']);
    $height = imagick_percent_filter($exact['height'], $image_info['height']);
    list($x, $y) = explode('-', $exact['anchor']);
    $x = image_filter_keyword($x, $width, $image_info['width']);
    $y = image_filter_keyword($y, $height, $image_info['height']);
  }
  else {
    $width = $image_info['width'] + $relative['leftdiff'] + $relative['rightdiff'];
    $height = $image_info['height'] + $relative['topdiff'] + $relative['bottomdiff'];
    $x = $relative['leftdiff'];
    $y = $relative['topdiff'];
  }
  return array(
    $width,
    $height,
    $x,
    $y,
  );
}