4 ms·
LZW is a lovely algorithm. It's simple enough to explain in a page of pseudocode and fast enough to run on 1980s hardware easily. The compression rate is "good
by bbanyc 7y ago
LZW is a lovely algorithm. It's simple enough to explain in a page of pseudocode and fast enough to run on 1980s hardware easily. The compression rate is "good enough." If not for the patent issue, there'd be no reason to switch to the marginally better Deflate (which was only created in response to the patent). A shame Unisys got greedy and killed it before its time.
Though that's got nothing to do with why GIFs got so popular. That's purely because GIF is the only format that could display animations on every browser since 1995. The timing of PNG was rather unfortunate - the PNG team had decided on not supporting animation because GIF animation was rare and adding it to the spec would've unnecessarily complicated things. They froze the spec, planning to submit it to W3C and IETF for standardization - and then Netscape, in full "move fast and break things" mode, released Navigator 2 with animated GIF support. So soon every GeoCities page is full of annoying sparkly GIFs, PNG only lets you make boring stills, and we've got to support both formats forever.
- SiVal 7y agoWell, a successor to JPEG called JPEG XL[1] that adds lossless compression, better lossy compression, the ability to further compress and then losslessly restore a traditional JPEG, HDR, animation, alpha channel, lots of other technical improvements, and a commitment by a long list of major players that if one of their patents is involved, it will be licensed at zero cost...is still scheduled to be officially published this month (Oct 2019). [1] https://en.wikipedia.org/wiki/JPEG#JPEG_XL https://en.wikipedia.org/wiki/JPEG#JPEG_XL
- gsich 7y agoJPEG also has lossless compression
- userbinator 7y agoIt's simple enough to explain in a page of pseudocode More like a paragraph... https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Welch#Encoding https://en.wikipedia.org/wiki/Lempel%E2%80%93Ziv%E2%80%93Wel... Personally, I like LZ more than LZW because it doesn't have to slowly "build up" the dictionary in the same way as LZW nor need bit-I/O (because you can have an 8, 16, or 32-bit "indicator", followed by that many literal or length/distance pairs) and thus makes for an even simpler (and faster) algorithm. The only downside is that it's more asymmetric, in that compression is usually far slower than decompression (which can be faster than memcpy() - see http://www.oldskool.org/pc/lz4_8088 http://www.oldskool.org/pc/lz4_8088 ) because the former has to do a lot of searching while the latter is mainly copying memory.