You are here

function image_gd_smartcrop_scale in Smart Crop 7

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

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

./image.gd.inc, line 21
libgd implementation of smartcrop action.

Code

function image_gd_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_gd_resize($image_data, round($ratio * $image_data->info['width']), round($ratio * $image_data->info['height']))) {
      return FALSE;
    }
  }
  return image_gd_smartcrop_crop($image_data, $requested_x, $requested_y);
}