Skip to content

MapleCCC/LZW-Compressor

Repository files navigation

LZW Compressor

License travisci codecov Code Style

Introduction

LZW is an archive format that utilize power of LZW compression algorithm. LZW compression algorithm is a dictionary-based loseless algorithm. It's an old algorithm suitable for beginner to practice.

Internal algorithm processes byte data. So it's applicable to any file types, besides text file. Although it may not be able to achieve substantial compression rate for some file types that are already compressed efficiently, such as PDF files and MP4 files.

Installation

Prerequisites: Python>=3.8, Git, pip.

One-liner installation recipe:

$ python -m pip install git+https://github.com/MapleCCC/LZW-Compressor.git#egg=LZW-Compressor

If editable mode installation is preferred:

# You can optionally create a virtual environment for isolation purpose
$ python -m virtualenv .venv
$ source .venv/Scripts/activate

# Install in editable mode
$ python -m pip install -e git+https://github.com/MapleCCC/LZW-Compressor.git#egg=LZW-Compressor

Usage

Use as command line tool:

# Compression
$ lzw compress [-o|--output <ARCHIVE>] <FILES>...

# Decompression
$ lzw decompress <ARCHIVE>

Use as module:

from LZW import lzw_compress, lzw_decompress

lzw_compress("a.lzw", "file1", "file2")
lzw_decompress("a.lzw")

Test

The project uses pytest and hypothesis as test framework. Property-based testing is adopted in favor of its flexibility and conciseness.

# Install test requirements
$ python -m pip install -r requirements-test.txt

# Base test
$ make test

# Test coverage
$ make test-cov

Benchmark

[TODO]

License

WTFPL 2.0

WTFPL

About

A compression and decompression program for LZW archive format

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published