Reputation: 11937
I have an animated gif much like this one, where the cyclic nature of the animation causes some frames to be repeated twice within one full loop of the animation.
(From here)
I am currently storing each frame separately in the gif. Is it possible to only store each repeated frame once, to effectively halve the storage space required?
I am creating my gif in MATLAB using the movie2gif
converter, but would be happy with an alternative method for gif creation or a post-processing tool.
EDIT
What I mean by the frame repetition is best explained in the context of this example image. There is a frame shown just as the left-hand ball leaves the row of balls. That exact frame is repeated a few frames later, when the left-hand ball is now on its way back to hit the row of balls again. Because of the ordering of frames, it is currently needed to store this frame twice.
To clarify what I am looking for: I want a way of saving the gif (or post-processing the gif) such that I can keep the full animation sequence (e.g. of 30 frames), but frames which repeat are soft-linked back to the first showing of them, thus removing the need to store them twice.
Upvotes: 5
Views: 1177
Reputation: 21563
Judging from the description of movie2gif and its input arguements, it does not appear to be possible. Furthermore, when reading how gifs work (and LZW) compression I can imagine that it is not even possible to reduce the size of a gif like this.
If you want to save only the images that are minimally required and don't mind building the image before you can see it, then you can just store each image and an indexing vector.
In your case it may be possible to find a way to just save half of the image, and then play it in a cycle: forward-backward-forward ... but I don't know whether this is possible.
Upvotes: 1