A lightweight Python utility to compress files and display size statistics, giving you quick insights into storage efficiency.
- Compress any file using a built-in compression algorithm.
- Display original vs. compressed file size, along with size reduction percentage.
- Easy command-line usage with clear prompts.
- No external dependencies—pure Python implementation. ([github.com][1], [github.com][2], [github.com][3])
-
Reads the given file in binary mode.
-
Applies compression logic (e.g., zlib-based or custom algorithm).
-
Writes the compressed output to a new file (e.g., with
.compressedsuffix). -
Calculates and prints:
- Original size
- Compressed size
- Compression ratio and percentage savings
-
Clone the repo:
git clone https://github.com/sagnikdatta2k6/fileCompressor.git cd fileCompressor -
(Optional) Create a virtual environment:
python3 -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate
-
Install dependencies: (if any are specified in
requirements.txt—if not, skip this step)pip install -r requirements.txt
Run the compressor with:
python file_conv.py <input_file> [<output_file>]<input_file>: The file you want to compress.[<output_file>]: (Optional) Specify output filename. Default will append.compressed.
Example:
python file_conv.py large_video.mp4 compressed_video.mp4After execution, you'll see output like:
Original size: 100 MB
Compressed size: 60 MB
You saved 40%!
- Quickly assess how much space compression saves for different file types.
- Lightweight CLI tool perfect for scripting or educational purposes.
- No external libs—run it anywhere Python is available.
-
No decompression support yet.
-
Uses basic compression—may not match optimized tools like
gziporzip. -
No GUI or batch mode.
-
Possible improvements:
- Add decompression functionality.
- Explore advanced compression (e.g.,
gzip,bz2). - Add batch processing or directory support.
- Include unit tests and CI integration.
Contributions and feedback are welcome! Here’s how to help:
-
Fork the repo
-
Create a feature branch:
git checkout -b feature/add-decompressor
-
Make your changes (and tests if applicable)
-
Open a Pull Request with a detailed description of your changes
This project is released under the MIT License—see the LICENSE file for details.
Thanks to open-source practitioners who build tools like this and inspire Python utilities everywhere!