Bug in GIF decoder

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
cleek
Posts: 2
Joined: 2014-04-10T11:35:43-07:00
Authentication code: 6789

Bug in GIF decoder

Post 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)
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: Bug in GIF decoder

Post 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:
Last edited by dlemstra on 2014-04-10T12:59:02-07:00, edited 2 times in total.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Bug in GIF decoder

Post 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
cleek
Posts: 2
Joined: 2014-04-10T11:35:43-07:00
Authentication code: 6789

Re: Bug in GIF decoder

Post by cleek »

ah. OK!
thanks.
Post Reply