You are here

function _imagefield_crop_resize in Imagefield Crop 7.3

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 imagefield_crop.module \_imagefield_crop_resize()
  4. 7.2 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 808

Code

function _imagefield_crop_resize($src, $preset, $scale = array(), $dst_file = NULL) {
  $image = image_load($src);
  if ($image) {
    $result = TRUE;
    if ($preset) {
      $result = $result && image_crop($image, $preset->cropbox_x, $preset->cropbox_y, $preset->cropbox_width, $preset->cropbox_height);
    }
    if ($scale && $scale['width'] < $preset->cropbox_width && $scale['height'] < $preset->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;
}