V
V
Vasya Surname2017-06-19 13:09:16
PHP
Vasya Surname, 2017-06-19 13:09:16

How to resize and save an animated GIF with ImageMagick?

This example doesn't work GIF is not animated

$imagick = new Imagick($_FILES['file']['tmp_name']);

$format = $imagick->getImageFormat();
if ($format == 'GIF') {
  $imagick = $imagick->coalesceImages();
  do {
     $imagick->resizeImage(500, 500, Imagick::FILTER_BOX, 1);
  } while ($imagick->nextImage());
  $imagick = $imagick->deconstructImages();
  $imagick->writeImages($name, true);

}

$imagick->clear();
$imagick->destroy();

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vyrkmod, 2017-06-19
@vyrkmod

If this is an animated gif, you will have to split it into frames, resize them, and then peck a new gif. Another option is to exec system tools with which such shamanism is not necessary.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question