| Versionen | |
|---|---|
| drupal6 | image_crop( |
| drupal7 | image_crop(stdClass $image, $x, $y, $width, $height) |
Crop an image to the rectangle specified by the given rectangle.
see image_load()
$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.
TRUE or FALSE, based on success.
includes/
<?php
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));
}
?>
Kommentare
Kommentar hinzufügen