We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Animated gifs don't resize well sometimes (Imagick)

When resizing this image:

I get this:

Note that I didn't specify it to be cropped, just smaller with the same ratio.

I noticed that merely saving the file using this code:

$image = new \Phalcon\Image\Adapter\Imagick($filePath);
$image->save($filePath);

Produces this exception:

images are not the same size /var/www/storage/media/397.gif @ error/layer.c/OptimizeLayerFrames/1026

Only when I get this exception, the resize is screwed up.

This happens not to all animated gifs, but maybe 50% of the ones I've tested.



85.5k
Accepted
answer
edited Oct '18

in my experience its best to use shell_exec to perform image magick operations.

imagick is a php wrapper extention that is not maintained for a VERY long time ( the guy said he has very little spare time to fix it )

So eather its image magick problem ( which i doubt ) or more likely imagick's fault.

//phalcon is just calling imagick functions, nothing special there.