3

Old-school computer graphics sometimes produced animations (cycles and fades) without actually redrawing anything to video memory, purely by updating the color palette.

Is it possible to do this in an animated gif? That is, optimise (reduce file-size of) the gif by only providing a single frame of (significant) raster content, but have each (delayed) animation frame update colour values in the (global) palette?

hidefromkgb
  • 5,834
  • 1
  • 13
  • 44
benjimin
  • 4,043
  • 29
  • 48

1 Answers1

4

The short answer is no.

According to the existing standard, every GIF frame containing a local palette must have its own data to be displayed using that palette, otherwise the local palette is of no use.

One of the possible solutions is to define your own GIF Application Extension block (like Netscape did; see the link) to store additional palettes and their time delays. Apparently, those extension blocks should appear after frames whose data they affect.

The downside of this approach is that no one except your decoder would support palette cycling unless your block type somehow makes its way to become a new de-facto standard.

Nevertheless, your handcrafted GIFs would remain valid for all other GIF decoders (even though without any palette cycling), as the standard requires them to silently ignore any GIF Application Extensions with IDs unknown to them.

hidefromkgb
  • 5,834
  • 1
  • 13
  • 44
  • 1. What if an individual GIF frame doesn't fill the entire image: does the local palette still get applied to surrounding areas of the canvas? (Otherwise, wouldn't it be possible to show more than 256 colours simultaneously?) 2. Isn't there also a global palette? Can an individual frame change the global palette? – benjimin Feb 08 '18 at 04:28
  • 1
    @benjimin [1] No, it does not, each local palette only belongs to the frame that defined it; and yes, there are GIFs that display more than 256 colors, [see here](https://stackoverflow.com/a/48669313/7019311). [2] Yes, the global palette can coexist with local palettes, but locals take priority each time they are present; frames can in no way influence the global palette. – hidefromkgb Feb 09 '18 at 14:33
  • More examples https://webmasters.stackexchange.com/questions/304/can-i-have-an-animated-gif-with-more-than-256-colours-per-frame/ – benjimin Feb 09 '18 at 23:19