Rbx-deflate - text compression library

Hello everyone! Recently I created a library with the help of dekkonot’s BitBuffer and 1waffle1’s text compression library.

This library implements a modified zlib/DEFLATE algorithm. I used the modified LZW algorithm that 1waffle1 created and I optimized/fixed before using Huffman coding.

The result is a compression algorithm that is relatively more efficient at the cost of some time performance. Here’s an example of what it can do. I ran Shakespeare’s Twelvth Night into the algorithm and it cut the character down from 112,375 to 57,625. Below that are the results of the standalone LZW and Huffman compression.

image

I will put out that due to the nature of every compression algorithm, there is always the chance that you might end up with encoded text that is a longer than what you put in. This algorithm tends to do well when your text has a lot of repeated elements.

Also due to the nature of the Huffman coding algorithm it is relatively slower in execution time (I also blame Roblox for not letting me use bit manipulation on buffers) so you could try to fork it to use batch execution.

8 Likes

Seems like a great application of deflate, but how do i use it? on the github i see that on the Deflate.story.lua fie you are calling local Deflate = require(game.ReplicatedStorage.Deflate), but i dont see a file called Deflate?
Maybe I need to add the full Deflate folder and call Deflate.init instead?

Just git clone the repo and sync with Rojo. You’ll see the module in ReplicatedStorage.

1 Like