function manualcrop_crop_and_scale_effect in Manual Crop 7
Image effect callback; Crop and scale an image resource.
Parameters
$image: An image object returned by image_load().
$data: An array of attributes, needed to perform the crop and scale effect, with the following items:
- "width": An integer representing the desired width in pixels.
 - "height": An integer representing the desired height in pixels.
 - "upscale": A boolean indicating that the image should be upscaled if the dimensions are larger than the original image.
 - "onlyscaleifcrop": A boolean indicating that the image should only be scaled if it was cropped.
 - "style_name": The style's machine name.
 
Return value
TRUE on success, FALSE on failure to crop and scale image.
See also
1 string reference to 'manualcrop_crop_and_scale_effect'
- manualcrop_image_effect_info in ./
manualcrop.module  - Implements hook_image_effect_info().
 
File
- ./
manualcrop.module, line 817  
Code
function manualcrop_crop_and_scale_effect(&$image, $data) {
  // The width and height will be possibly overwritten for the cropping,
  // so copy the data array for later.
  $scale_data = $data;
  $crop = manualcrop_load_crop_selection($image->source, $data['style_name']);
  if ($crop) {
    // Only crop if a crop was applied.
    $data['width'] = $crop->width;
    $data['height'] = $crop->height;
    $data['anchor'] = $crop->x . '-' . $crop->y;
    if (!image_crop_effect($image, $data)) {
      return FALSE;
    }
  }
  elseif (!empty($data['onlyscaleifcrop'])) {
    return TRUE;
  }
  else {
    // Automated crop, don't use image_scale_and_crop_effect() unless
    // upscaling is allowed or both image dimensions are bigger than
    // the desired dimensions.
    if ($scale_data['upscale'] || $image->info['width'] > $scale_data['width'] && $image->info['height'] > $scale_data['height']) {
      if (!image_scale_and_crop_effect($image, $scale_data)) {
        return FALSE;
      }
    }
    else {
      if (!image_crop_effect($image, $scale_data)) {
        return FALSE;
      }
    }
  }
  return image_scale_effect($image, $scale_data);
}