1

GIFs are images that can be animated, i.e. consist of a sequence of frames. There are two types of GIFs in the world: Type A stores each frame separately, and type B instead stores the differences between subsequent GIFs.

I am loading GIFs using imageio which works fine for type A but only returns differences for type B. How can I easily get the full frames instead?

This is how I get the images:

reader = imageio.get_reader(filename)
for _ in range(reader.get_length()):
    PIL.Image.fromarray(reader.get_next_data().copy()).convert('RGBA')

And this is the result when I use a GIF of type A (left, good) versus type B (right, bad) for my hug-an-image algorithm:

enter image description here enter image description here

Inputs:

enter image description here enter image description here

xjcl
  • 12,848
  • 6
  • 67
  • 89
  • I'm thinking maybe composing subsequent frames using something like `alpha_composite` might work, but (A) there has to be a simpler way and (B) I don't know how to tell whether a GIF is "difference-based" :/ – xjcl Jan 19 '20 at 00:41
  • The difference-based GIF has the meta-data `'extension': (b'ImageMagick', 822)`, maybe that indicates it is difference-based? – xjcl Jan 19 '20 at 00:46
  • Relevant [pil-is-showing-all-the-previous-frames-in-the-gif](https://stackoverflow.com/questions/55313887/pil-is-showing-all-the-previous-frames-in-the-gif) – stovfl Jan 19 '20 at 12:21

0 Answers0