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);
}
Imagick::cropImage
(No version information available, might be only in CVS)
Imagick::cropImage — Extracts a region of the image
Descrizione
bool Imagick::cropImage
( int $width
, int $height
, int $x
, int $y
)
Avviso
Questa funzione, al momento non è documentata; è disponibile soltanto la lista degli argomenti.
Extracts a region of the image.
Elenco dei parametri
- 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
Valori restituiti
Restituisce TRUE in caso di successo.
Errori/Eccezioni
Lancia una ImagickException in caso di errore.
Imagick::cropImage
vincent dot hoen at gmail dot com
02-Aug-2007 06:35
02-Aug-2007 06:35
vincent dot hoen at gmail dot com
01-Aug-2007 08:39
01-Aug-2007 08: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();
