PHP Doku:: Extracts a region of the image - function.imagick-cropimage.html

Verlauf / Chronik / History: (3) anzeigen

Sie sind hier:
Doku-StartseitePHP-HandbuchFunktionsreferenzBildverarbeitung und -generierungImage Processing (ImageMagick)The Imagick classImagick::cropImage

Ein Service von Reinhard Neidl - Webprogrammierung.

The Imagick class

<<Imagick::convolveImage

Imagick::cropThumbnailImage>>

Imagick::cropImage

(PECL imagick 2.0.0)

Imagick::cropImageExtracts a region of the image

Beschreibung

bool Imagick::cropImage ( int $width , int $height , int $x , int $y )
Warnung

Diese Funktion ist bis jetzt nicht dokumentiert. Es steht nur die Liste der Argumente zur Verfügung.

Extracts a region of the image.

Parameter-Liste

width

The width of the crop

height

The height of the crop

x

The X coordinate of the cropped region's top left corner

y

The Y coordinate of the cropped region's top left corner

Rückgabewerte

Liefert TRUE bei Erfolg.

Fehler/Exceptions

Wirft ImagickException bei Fehlern.


4 BenutzerBeiträge:
- Beiträge aktualisieren...
ElPadre
5.11.2010 17:55
Actually, the Imagick::setImagePage(0,0,0,0) is also handy with jpgs and pngs, if you plan to do any more changes on the cropped image that involves positioning and/or gravity (I created a script that does crop, face blur and watermarking in one go, and had a hell of a time determining why the blurs and the watermark text never showed up...).
Christian Dehning
9.04.2010 12:57
When cropping gif-images (I had no problems with jpg and png images), the canvas is not removed. Please run the following command on the cropped gif, to remove the blank space:

$im->setImagePage(0, 0, 0, 0);
vincent dot hoen at gmail dot com
2.08.2007 15:35
There is an easiest way to crop an image : 

$picture = new Imagick('animated_gif.gif');

foreach($picture as $frame){
    $frame->cropImage($width, $height, $x, $y);
}
vincent dot hoen at gmail dot com
1.08.2007 17:39
If you're working with animated gif you might want to process this way (Probably not the best, but at least it works) :

$picture = new Imagick('animated_gif.gif');

//Crop first image
$picture->cropImage($width, $height, $x, $y);

//Crop every other image
while($picture->hasNextImage()){
    $this->nextImage();
    $this->cropImage($width, $height, $x, $y);
}

//display image
$picture->getImageBlob();



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)