- $magick = new Imagick($imagefile->filepath);
- $magick = $magick->coalesceImages();
- $magick->setIteratorIndex(0);
- do {
- $magick->cropImage($box['w'], $box['h'], $box['x'], $box['y']);
- $magick->thumbnailImage($box['width'], $box['height']);
- $magick->setImagePage($box['width'], $box['height'], 0, 0);
- } while ($magick->nextImage());
- $magick = $magick->deconstructImages();
+ break;
+ }
+ return true;
+ }
+
+ protected function resizeImageFileAnimatedGif(ImageFile $imagefile, $outpath, array $box)
+ {
+ $magick = new Imagick($imagefile->filepath);
+ $magick = $magick->coalesceImages();
+ $magick->setIteratorIndex(0);
+ do {
+ $magick->cropImage($box['w'], $box['h'], $box['x'], $box['y']);
+ $magick->thumbnailImage($box['width'], $box['height']);
+ $magick->setImagePage($box['width'], $box['height'], 0, 0);
+ } while ($magick->nextImage());
+ $magick = $magick->deconstructImages();
+
+ // $magick->writeImages($outpath, true); did not work, had to use filehandle
+ // There's been bugs for writeImages in php5-imagick before, probably now too
+ $fh = fopen($outpath, 'w+');
+ $success = $magick->writeImagesFile($fh);
+ fclose($fh);
+ $magick->destroy();