/lzsslib

A library for inflating and deflating LZSS (Lempel, Ziv, Storer, Szymanski) buffers.

Primary LanguagePython

liblzss

GitHub Workflow Status PyPI

Liblzss is an small library for inflating and deflating LZSS (Lempel, Ziv, Storer, Szymanski) buffers.

The LZSS format is originally described in a paper titled "Data Compression via Textual Substitution" published in Journal of the ACM, 29(4):928-951, 1982 by J.A. Storer and T.G. Szymanski.

Installing

Install and update using pip:

$ pip install -U lzsslib

Usage

The following example shows how to decompress a file using default options.

from pathlib import Path
from lzsslib.decompress import LzssDecompressor

# Create a decompressor object with default options
decomp = LzssDecompressor()

# Open an input and output files
fin = Path('input.lzss').open(mode='rb')
fout = Path('output.bin').open(mode='wb')

# Read the input, decompress and write
while (buffer := fin.read(1024)):
    out = decomp.decompress(buffer, remaining_size)
    fout.write(out)

# Ensure output is written and close
fout.flush()
fin.close()
fout.close()

Links