| 5 image.inc | image_crop($source, $destination, $x, $y, $width, $height) |
| 6 image.inc | image_crop( |
| 7 image.inc | image_crop(stdClass $image, $x, $y, $width, $height) |
| 8 image.inc | image_crop(stdClass $image, $x, $y, $width, $height) |
Crop an image to the rectangle specified by the given rectangle.
Parameters
$image: An image object returned by image_load().
$x: The top left coordinate, in pixels, of the crop area (x axis value).
$y: The top left coordinate, in pixels, of the crop area (y axis value).
$width: The target width, in pixels.
$height: The target height, in pixels.
Return value
TRUE on success, FALSE on failure.
See also
Related topics
3 calls to image_crop()
4 string references to 'image_crop'
File
- includes/
image.inc, line 331 - API for manipulating images.
Code
function image_crop(stdClass $image, $x, $y, $width, $height) {
$aspect = $image->info['height'] / $image->info['width'];
if (empty($height)) {
$height = $width / $aspect;
}
if (empty($width)) {
$width = $height * $aspect;
}
$width = (int) round($width);
$height = (int) round($height);
return image_toolkit_invoke('crop', $image, array($x, $y, $width, $height));
}
Login or register to post comments