Page 1 of 1

Bug in GIF decoder

Posted: 2014-04-10T11:37:55-07:00
by cleek
It looks like the GIF decoder has a problem somewhere.

Using this as img.gif: http://upload.wikimedia.org/wikipedia/c ... imated.gif

When I run :

convert img.gif[0] frame0.gif
...and...
convert img.gif[1] frame1.gif

I get the correct images.

But when I run:
convert img.gif[2] frame2.gif

The output is corrupt. It looks like a lot of the pixels have been set to white for some reason.

I also see that problem in frame 6.

I'd assume it was a bad GIF, but Firefox, and IE and all the on-line GIF frame extractors I tried were able to show all the frames without any problem.

(I'm using the IM 6.8.8 on Windows)

Re: Bug in GIF decoder

Posted: 2014-04-10T12:24:27-07:00
by dlemstra
The frames of that gif image are optimized so each frame does not contain the exact version of that frame. If you want that you will have to -coalesce it first.

Code: Select all

convert Prague_Astronomical_Clock_animated.gif -coalesce -delete 0-1 -delete 1--1 test.gif
The delete operation first removes frames 0 and 1 and the second delete removes the frames from 1 till -1 (last image). This will allow you to get the second frame.

Edit (less code):

Code: Select all

convert img.gif -coalesce ( -clone 2 -write 2.gif ) null:

Re: Bug in GIF decoder

Posted: 2014-04-10T12:33:06-07:00
by fmw42
If you want to look at all gif frames, then a simple variation of the above from dlemstra is

Code: Select all

convert Prague_Astronomical_Clock_animated.gif -coalesce +adjoin test.gif
you will get images, test-0.gif test-1.gif ... test-N.gif

Re: Bug in GIF decoder

Posted: 2014-04-10T13:02:03-07:00
by cleek
ah. OK!
thanks.