function image_crop_effect
image_crop_effect(&$image, $data)
Image effect callback; Crop an image resource.
Parameters
$image: An image object returned by image_load().
$data: An array of attributes to use when performing the crop effect with the following items:
- "width": An integer representing the desired width in pixels.
- "height": An integer representing the desired height in pixels.
- "anchor": A string describing where the crop should originate in the form of "XOFFSET-YOFFSET". XOFFSET is either a number of pixels or "left", "center", "right" and YOFFSET is either a number of pixels or "top", "center", "bottom".
Return value
TRUE on success. FALSE on failure to crop image.
See also
File
- modules/image/image.effects.inc, line 177
- Functions needed to execute image effects provided by Image module.
Code
function image_crop_effect(&$image, $data) { // Set sane default values. $data += array( 'anchor' => 'center-center', ); list($x, $y) = explode('-', $data['anchor']); $x = image_filter_keyword($x, $image->info['width'], $data['width']); $y = image_filter_keyword($y, $image->info['height'], $data['height']); if (!image_crop($image, $x, $y, $data['width'], $data['height'])) { watchdog('image', 'Image crop failed using the %toolkit toolkit on %path (%mimetype, %dimensions)', array('%toolkit' => $image->toolkit, '%path' => $image->source, '%mimetype' => $image->info['mime_type'], '%dimensions' => $image->info['width'] . 'x' . $image->info['height']), WATCHDOG_ERROR); return FALSE; } return TRUE; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!image!image.effects.inc/function/image_crop_effect/7.x