Ubuntu – Fix animated GIF images which eog can’t open, but Firefox and ImageMagick can

convert-commandeoggifimage processingimagemagick

I received a collection of animated GIF images from a friend, but I am unable to open some of them them with the standard image viewer eog.

The error messages showing up when trying to open them include:

  • GIF image loader cannot understand this image

  • Circular table entry in GIF file

  • Stack overflow

However, the images are not corrupt, because I can open them with Firefox without problems, also with the ImageMagick viewer, which does not play the animation automatically though.

Examining the GIFs with file returns the output below, both for the images I can and cannot open (varying sizes though):

GIF image data, version 89a, 400 x 300

I want to be able to open all these images in eog. Can I somehow "fix" the "broken" images to make them readable for the standard image viewer, e.g. by using ImageMagick's conversion abilities to turn them into something else and back?

Best Answer

Usually when some program can't open certain GIFs it's because of optimization used for this image.

You can try running ImageMagick with the -coalesce option. This will redraw each frame with all the details from previous frames. This will increase file size, but undo complex frame optimizations.

convert original.gif -coalesce unoptimized.gif

If this doesn't help, please provide a sample GIF with this problem.