GithubHelp home page GithubHelp logo

srijanmukherjee / huffman-compression Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 25 KB

A huffman coding based text compression utilility tool.

License: MIT License

Makefile 2.62% C++ 92.08% Python 5.30%
compression cpp huffman-coding

huffman-compression's Introduction

huffman-compression

A simple cli tool to compress/decompress text (for now) files using huffman coding algorithm.

Getting started

# Clone the repository (SSH)
git clone --recurse-submodules [email protected]:srijanmukherjee/huffman-compression.git

# Clone the repository (HTTPS)
git clone --recurse-submodules https://github.com/srijanmukherjee/huffman-compression.git

# initialize build directory
make init

# to build the project
make

# to compress a text file
./build/huffman filepath

# to decompress
./build/huffman -d filepath

Usage

Usage: huffman [--help] [--version] [--verbose] [--decompress] [--output VAR] file

Positional arguments:
  file              path to file 

Optional arguments:
  -h, --help        shows help message and exits 
  -v, --version     prints version information and exits 
  --verbose         enable verbose output 
  -d, --decompress  decompress file 
  -o, --output      output file path [default: ""]

Result

  • examples/sample0.txt
1009K sample0.txt.bin
1.8M  examples/sample0.txt

Dependencies

License

This project is available under the MIT license

huffman-compression's People

Contributors

srijanmukherjee avatar

Watchers

 avatar

huffman-compression's Issues

Compressed file size greater than original file size

If the compressed size (table + compressed content) > original file size, we will not put the compressed content in the file instead do something like set some sort of flag and put the original content.

The flag will denote that the content of the compressed file contains the original content, so removing the flag will give the uncompressed file.

Example:

  • Original file (3 bytes)
abc
  • Table size = 3 * 4 + 3 bytes
  • Content = 4 bits

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.