Imagick::coalesceImages

(PECL imagick 2, PECL imagick 3)

Imagick::coalesceImagesCompone un conjunto de imágenes

Descripción

Imagick::coalesceImages(): Imagick

Compone un conjunto de imágenes mientras se respeten indices de página y métodos de disposición. Las secuencias de animación GIF, MIFF, y MNG normalmente comienzan con un fondo de imagen y cada imagen subsiguiente varía en tamaño e índice. Devuelve un nuevo objeto Imagick donde cada imagen de la secuencia es del mismo tamaño que la primera y compuesta con la siguiente imagen de la secuencia.

Valores devueltos

Devuelve un nuevo objeto Imagick en caso de éxito.

Errores/Excepciones

Lanza ImagickException en caso de error.

add a note

User Contributed Notes 3 notes

up
6
ktr
12 years ago
resize and/or crop an animated GIF

<?php
$image = new Imagick($file_src);

$image = $image->coalesceImages();

foreach ($image as $frame) {
  $frame->cropImage($crop_w, $crop_h, $crop_x, $crop_y);
  $frame->thumbnailImage($size_w, $size_h);
  $frame->setImagePage($size_w, $size_h, 0, 0);
}

$image = $image->deconstructImages();
$image->writeImages($file_dst, true);
?>
up
2
vikomic at gmail dot com
14 years ago
Here goes an exaple how to resize GIF-s.<?php$imagick = new Imagick("original.gif");$format = $imagick->getImageFormat();if ($format == 'GIF') {  $imagick = $imagick->coalesceImages();  do {     $imagick->resizeImage(120, 120, Imagick::FILTER_BOX, 1);  } while ($imagick->nextImage());  $imagick = $imagick->deconstructImages();  $imagick->writeImages('new_120x120.gif', true);  // can be added some more gifs  $imagick = $imagick->coalesceImages();  do {     $imagick->resizeImage(100, 100, Imagick::FILTER_BOX, 1);  } while ($imagick->nextImage());  $imagick = $imagick->deconstructImages();  $imagick->writeImages('new_100x100.gif', true);}$imagick->clear();$imagick->destroy();?>You can use any resize method (resizeImage) with this example.This example works fine with *imagick module version 2.2.1-dev*, but doesn't work correctly with *imagick module version 3.0.1*.
up
1
Anony
9 years ago
If you wish to open an animated gif, don't ping the image with $imagick->pingImage(), you will get the same amount of frames you have in the gif, added to the start - but they're all black with stripes. So you have then double the amounts of frames the gif actually has.
To Top