This project implements text and image compression using multiple methods, including Huffman, Run-Length Encoding (RLE), and Lempel-Ziv-Welch (LZW) for text, and Huffman and RLE for images. Each method offers different approaches to achieve efficient compression and decompression of files. Below are detailed instructions for using each method.
- Sample File: Ensure the sample text file is in the same directory as the code.
- Setup: Edit the code to specify the sample file:
const char* inputFilename = "sample.txt";
- Execution:
- Compile and run the
.c
file.
- Compile and run the
- Output:
- A compressed
.bin
file. - A decompressed
.txt
file version of the.bin
file.
- A compressed
- Sample File: Place the sample file in the same directory.
- Setup: Update the input filename in the code:
char *input = read_file("sample.txt", &input_length);
- Execution:
- Compile and run the
.c
file.
- Compile and run the
- Output:
- A compressed
.txt
file. - A decompressed
.txt
file version of the compressed output.
- A compressed
- Sample File: Place the text file in the directory.
- Execution:
- Compile and run the
.c
file. - Input the file name when prompted.
- Compile and run the
- Output: Generates
compressed.bin
as the compressed file.
- Setup: Place the
compressed.bin
file from the compression step in the directory. - Execution:
- Compile and run the
.c
file.
- Compile and run the
- Output: Generates
decompressed.txt
as the decompressed output.
- The "Sample Text" folder contains sample text files for testing the text compression methods.
- You are free to test any text file. Simply place the file in the directory and update the code as instructed for each compression method.
- Sample File: Place the
.bmp
file in the directory. - Setup: Specify the image file in the code:
const char *inputFileName = "sample.bmp";
- Execution:
- Compile and run the
.c
file.
- Compile and run the
- Output:
- A
.bin
compressed file. - A decompressed
.bmp
file version of the.bin
file.
- A
- Sample File: Place the
.bmp
file in the directory. - Setup: Update the file name in the code:
const char *inputFile = "sample.bmp";
- Execution:
- Compile and run the
.c
file.
- Compile and run the
- Output:
- A
.rle
compressed file. - A decompressed
.bmp
file version of the.rle
file.
- A
- The "Sample Image" folder contains
.bmp
images for testing the image compression methods.
- For compatibility with the compression algorithms, images in formats such as
.png
,.jpeg
, or.bmp
can be standardized by opening the image in Microsoft Paint and saving it as a.bmp
file. This ensures uniform formatting for processing with the compression code.
This README provides all the necessary information to run and test the compression methods. Adjust file names and paths as needed, and enjoy exploring the compression techniques!