Pure Lua compressors and decompressors with high compression ratio using DEFLATE/zlib format.
LibDeflate is pure Lua compressor and decompressor with high compression ratio, which compresses almost as good as zlib. It compresses using the same algorithm as ZIP.
Documentation is hosted on Github.
Below is a simple benchmark compared with another pure Lua compressor LibCompress.
The size of The input data is 158492 bytes. The benchmark runs on Lua 5.1.5 interpreter.
NOTE: The compression method used by LibDeflate here is LibDeflate:CompressDeflate (Compress using raw DEFLATE format)
LibCompress (LZW): 1.20 compression ratio in 52ms.
LibCompress (Huffman): 1.36 compression ratio in 50ms.
LibDeflate(Level 1): 3.15 compression ratio in 68ms.
LibDeflate(Level 5): 3.68 compression ratio in 116ms.
LibDeflate(Level 8): 3.71 compression ratio in 189ms.
LibDeflate with compression level 1 compresses as fast as LibCompress, but already produces significantly smaller file than LibCompress. High compression level takes a bit more time to get better compression.
Real Project Sample Code (With backward compatibility)
Other places to get LibDeflate
- LibDeflate is also uploaded to WoWInterface. The releases on WoWInterface and Curseforge are identical.
- You can also get LibDeflate from LuaRocks using the command "luarocks install libdeflate", if you are not using the Lua interpreter in World of Warcraft.
- All release files can also be downloaded from the Github release page
LibDeflate is licensed under the zlib license.
Credits and Disclaimer
The following projects are used to the help to test the correctness of this program. The code of the main program (LibDeflate.lua) does not use their code directly, but uses their ideas and algorithms. Their original licenses shall be comply when used.
zlib, by Jean-loup Gailly (compression) and Mark Adler (decompression). Licensed under zlib License. puff, by Mark Adler. Licensed under zlib License. LibCompress, by jjsheets and Galmok of European Stormrage (Horde). Licensed under GPLv2. WeakAuras2. Licensed under GPLv2.