You are here

function _imagefield_crop_resize in Imagefield Crop 7.2

Same name and namespace in other branches
  1. 5 imagefield_crop.module \_imagefield_crop_resize()
  2. 6 imagefield_crop_widget.inc \_imagefield_crop_resize()
  3. 7.3 imagefield_crop.module \_imagefield_crop_resize()
  4. 7 imagefield_crop.module \_imagefield_crop_resize()

Crop the image and resize it.

2 calls to _imagefield_crop_resize()
imagefield_crop_field_insert in ./imagefield_crop.module
Implements hook_field_insert().
imagefield_crop_field_update in ./imagefield_crop.module
Implements hook_field_update().

File

./imagefield_crop.module, line 918
Functionality and Drupal hook implementations for the Imagefield Crop module.

Code

function _imagefield_crop_resize($src, $input = NULL, $scale = NULL, $dst_file = NULL) {
  $image = image_load($src);
  if ($image) {
    $result = TRUE;
    if ($input) {
      $result = $result && image_crop($image, $input['cropbox_x'], $input['cropbox_y'], $input['cropbox_width'], $input['cropbox_height']);
    }
    if ($scale && $scale['width'] < $input['cropbox_width'] && $scale['height'] < $input['cropbox_height']) {
      $result = $result && image_scale_and_crop($image, $scale['width'], $scale['height']);
    }
    $result = $result && image_save($image, isset($dst_file->uri) ? drupal_realpath($dst_file->uri) : $src);
    module_invoke_all('imagefield_crop_image_crop_updated', $dst_file);
    return $result;
  }
  return FALSE;
}