image_crop

  1. drupal
    1. drupal6
    2. drupal7
Versionen
drupal6 image_crop($source, $destination, $x, $y, $width, $height)
drupal7 image_crop(stdClass $image, $x, $y, $width, $height)

Crop an image to the rectangle specified by the given rectangle.

see image_load()

Übergabeparameter

$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.

Rückgabewert

TRUE or FALSE, based on success.

See also

image_scale_and_crop()

image_gd_crop()

Verwandte Themen

▾ 2 functions call image_crop()

ImageToolkitTestCase::testCrop in modules/simpletest/tests/image.test
Test the image_crop() function.
image_scale_and_crop in includes/image.inc
Scales an image to the exact width and height given.

Code

includes/image.inc, line 288

<?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

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen