All Projects → manassra → LZ77-Compressor

manassra / LZ77-Compressor

Licence: MIT license
A simplified implementation of the LZ77 compression algorithm

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to LZ77-Compressor

Lizard
Lizard (formerly LZ5) is an efficient compressor with very fast decompression. It achieves compression ratio that is comparable to zip/zlib and zstd/brotli (at low and medium compression levels) at decompression speed of 1000 MB/s and faster.
Stars: ✭ 408 (+482.86%)
Mutual labels:  compression, compressor
Rust Brotli
Brotli compressor and decompressor written in rust that optionally avoids the stdlib
Stars: ✭ 504 (+620%)
Mutual labels:  compression, compressor
EasyCompressor
⚡ A compression library that implements many compression algorithms such as LZ4, Zstd, LZMA, Snappy, Brotli, GZip, and Deflate. It helps you to improve performance by reducing Memory Usage and Network Traffic for caching.
Stars: ✭ 167 (+138.57%)
Mutual labels:  compression, compressor
Turbopfor Integer Compression
Fastest Integer Compression
Stars: ✭ 520 (+642.86%)
Mutual labels:  compression, compressor
Minify
CSS & JavaScript minifier, in PHP. Removes whitespace, strips comments, combines files (incl. @import statements and small assets in CSS files), and optimizes/shortens a few common programming patterns.
Stars: ✭ 1,710 (+2342.86%)
Mutual labels:  compression, compressor
roadroller
Roadroller: Flattens Your JavaScript Demo
Stars: ✭ 253 (+261.43%)
Mutual labels:  compression, compressor
Lzbench
lzbench is an in-memory benchmark of open-source LZ77/LZSS/LZMA compressors
Stars: ✭ 490 (+600%)
Mutual labels:  compression, compressor
Stdpack.c
Collection of small public domain de/compressors in plain C.
Stars: ✭ 73 (+4.29%)
Mutual labels:  compression, compressor
Squeezer
Flexible general-purpose compressor with a touch of citrus
Stars: ✭ 78 (+11.43%)
Mutual labels:  compression, compressor
Turbobench
Compression Benchmark
Stars: ✭ 211 (+201.43%)
Mutual labels:  compression, compressor
Compressor
An android image compression library.
Stars: ✭ 6,745 (+9535.71%)
Mutual labels:  compression, compressor
zlib
Compression and decompression in the gzip and zlib formats
Stars: ✭ 32 (-54.29%)
Mutual labels:  compression
memscrimper
Code for the DIMVA 2018 paper: "MemScrimper: Time- and Space-Efficient Storage of Malware Sandbox Memory Dumps"
Stars: ✭ 25 (-64.29%)
Mutual labels:  compression
bytepress
Compressor for .NET executables
Stars: ✭ 33 (-52.86%)
Mutual labels:  compressor
imagezero
Fast Lossless Color Image Compression Library
Stars: ✭ 49 (-30%)
Mutual labels:  compression
minibsdiff
A miniature, portable version of bsdiff.
Stars: ✭ 115 (+64.29%)
Mutual labels:  compression
AudioEffectDynamics
Dynamics Processor (Gate, Compressor & Limiter) for the Teensy Audio Library
Stars: ✭ 23 (-67.14%)
Mutual labels:  compression
mmtf
The specification of the MMTF format for biological structures
Stars: ✭ 40 (-42.86%)
Mutual labels:  compression
SSffmpegVideoOperation
This is a library of FFmpeg for android... 📸 🎞 🚑
Stars: ✭ 261 (+272.86%)
Mutual labels:  compression
MV-Tractus
A simple tool to extract motion vectors from h264 encoded videos.
Stars: ✭ 83 (+18.57%)
Mutual labels:  compression

A Python LZ77-Compressor

A simplified implementation of the LZ77 compression algorithm in python.

Implementation

The compressor follows the implementation of the standard LZ77 compression algorithm. Using a lookahead buffer at a certain position, the longest match is found from a fixed size window of data history. If a match is found, the substring is replaced with a pointer (distance) to the start of the match, and the length of the match.

Setup and Dependencies

First, you will need to clone the repository:

  git clone https://github.com/manassra/LZ77-Compressor.git

The LZ77Compressor uses the bitarray python module as the only dependency.

This dependency can be install by using pip, the python package manager, as follows:

  pip install -r requirements.txt 

Usage

  from LZ77 import LZ77Compressor
  
  compressor = LZ77Compressor(window_size=20) # window_size is optional
Options

window_size an optional integer specifying the length of the history window. Default is 20.

Compressing Files

  input_file_path = '/Users/manassra/...'
  output_file_path = '/Users/manassra/...'
  
  # compress the input file and write it as binary into the output file
  compressor.compress(input_file_path, output_file_path)
  
  # or assign compressed data into a variable 
  compressed_data = compressor.compress(input_file_path)
Options

verbose if True, the compression description is printed to standard output.

Example: if a file has "hello hello", verbose will print the following description: <0, h> <0, e> <0, l> <0, l> <0, o> <0, > <1, 6, 5>

Decompressing Files

  input_file_path = '/Users/manassra/...'
  output_file_path = '/Users/manassra/...'
  
  # decompress the input file and write it as binary into the output file
  compressor.decompress(input_file_path, output_file_path)
  
  # or assign decompressed data into a variable 
  decompressed_data = compressor.decompress(input_file_path)

Examples

the folder /examples has the following files:

input.txt, a file containing some text (size: 231 bytes)

compressed_window_100.txt, a compressed output of it using this algorithm with window size of 100 (size: 71 bytes, 30% of original size)

decompressed.txt, the decompressed file back to its original form (same as input.txt, size: 231 bytes)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].