You are here

function image_imagick_smartcrop_scale in Imagick 7

Scale and crop an image to the specified size using Imagemagick.

Parameters

$image_data An image object.:

$requested_x The requested image width.:

$requested_y The requested image height.:

$upscale TRUE if upscaling is allowed.:

Return value

TRUE if successful.

File

imagick_smartcrop/imagick_smartcrop.inc, line 12

Code

function image_imagick_smartcrop_scale(stdClass $image_data, $requested_x, $requested_y, $upscale) {
  $ratio = max($requested_x / $image_data->info['width'], $requested_y / $image_data->info['height']);
  if ($ratio <= 1 || $upscale) {
    if (!image_imagick_resize($image_data, round($ratio * $image_data->info['width']), round($ratio * $image_data->info['height']))) {
      return FALSE;
    }
  }
  return image_imagick_smartcrop_crop($image_data, $requested_x, $requested_y);
}