Get the latest tech news

LZW and GIF explained


s a way of compressing data that takes advantage of repetition of strings in the data. Since raster data usually contains a lot of this repetition, LZW is a good way of compressing and decompressing it.

I hope this little document will help enlighten those of you out there who want to know more about the Lempel-Ziv Welch (LZW) compression algorithm, and, specifically, the implementation that GIF uses. In part of the header of a GIF file, there is a field, in the Raster Data stream, called "code size". The packaging of codes into a bitsream for the raster data is also a potential stumbling block for the novice encoder or decoder.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of GIF

GIF

Photo of LZW

LZW

Related news:

News photo

Gifski: Optimized GIF Encoder

News photo

Logic gates using liquids (2019)

News photo

Turn a Video into a GIF on iPhone and iPad