gifsplit
gifsplit copied to clipboard
gif animation frame extractor
== Introduction ==
gifsplit takes an animated GIF and extracts its frames as PNG or JPEG images. Its distinguishing feature over other tools like ImageMagick and gifsicle is that it does not load the original GIF entirely into memory, but instead writes out the frames progressively.
gifsplit resolves any partial frames and outputs only complete frames. It (hopefully) correcty handles the various GIF frame disposal methods and should produce output equivalent to what a web browser would produce. Metadata such as the duration of each frame (in centiseconds) and the number of times the entire animation should loop are output on standard out.
== Dependencies ==
libpng-dev, libgif-dev, libjpeg-dev.
== Installation ==
$ make $ sudo make install
== Usage ==
Run 'gifsplit -h' for more information.
Basic usage: $ gifsplit input.gif output_base
== Why output PNGs and not GIFs? ==
Because displayed GIF frames can have more than 256 colors[1].
Although individual GIF frames as stored cannot have more than 256 colors, they can be displayed on top of the previous frames. When combined, multiple partial frames affecting different sections of the canvas might result in a merged frame that has more than 256 colors.
Currently, gifsplit is quite naive and does not know how to merge colormaps at all, even if they could be losslessly merged. Therefore, it will only output 256-color PNGs when the GIF only has a single global colormap, or when every frame completely covers the image and does not retain any information from the underlying frame (the frames may still have transparent pixels, but must use background disposal if they do, to ensure that nothing "shows through" from previous frames). Otherwise, gifsplit will switch to truecolor mode and start outputting truecolor PNGs instead (it will switch back to 256-color mode if it encounters a full-coverage frame again).
In JPEG output mode, all frames are truecolor, for obvious reasons. Additionally, transparent pixels are rendered as white in JPEGs.
[1] http://phil.ipal.org/tc.html