2

I'm using ImageMagick to do some stuff with GIF images.

One of my steps is identifying the number of frames in an image.
I'm calling identify via node-imagemagick (and later gm) like this:

identify -format '%T,%w,%h ' test.gif

Most of the time I correctly get 53 space-separated values for 53 frames.
But sometimes I get 47 or 50 frames for the same GIF image (that has 53 frames).

How can this possibly happen?

I'm running convert -coalesce -append test.gif other.gif at the same time, but it shouldn't touch the original image, right? Moreover I checked and the original image is just fine, even when wrong number of frames is reported.

I can't even reproduce this consistently. Where do I look for the problem?

This seems to happen when I'm running several ImageMagick processes concurrently (on different files).

I'm using ImageMagick 6.8.7-9 Q16 x86_64 2013-12-11.

The image in question:

(But I've had this happen to other images.)

max pleaner
  • 26,189
  • 9
  • 66
  • 118
Dan Abramov
  • 264,556
  • 84
  • 409
  • 511
  • Can you put up a link to your image? – dlemstra Dec 11 '13 at 21:42
  • @dlemstra: Sure, just added it. However I've had this issue with another image as well. – Dan Abramov Dec 11 '13 at 21:46
  • 1
    Add a `%s` to the format string to get the frame number ("scene"). Perhaps you can identify if a frame is being dropped during the decode, dropped from the front, or dropped at the end. Using `-verbose` also dumps a whole lot of information, including a "X of Y" string for each frame. – Charles Dec 11 '13 at 23:57
  • @Charles: You beat me to it! Stay tuned, I'm posting an explanation. – Dan Abramov Dec 11 '13 at 23:57

1 Answers1

2

This was not an ImageMagick problem at all.
My code for downloading the image to the server was faulty, always skipping some last fifty bytes or so.

This was too easy to miss because it didn't impact GIF's quality severely.

Dan Abramov
  • 264,556
  • 84
  • 409
  • 511