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
.cfile.
- Compile and run the
- Output:
- A compressed
.binfile. - A decompressed
.txtfile version of the.binfile.
- 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
.cfile.
- Compile and run the
- Output:
- A compressed
.txtfile. - A decompressed
.txtfile version of the compressed output.
- A compressed
- Sample File: Place the text file in the directory.
- Execution:
- Compile and run the
.cfile. - Input the file name when prompted.
- Compile and run the
- Output: Generates
compressed.binas the compressed file.
- Setup: Place the
compressed.binfile from the compression step in the directory. - Execution:
- Compile and run the
.cfile.
- Compile and run the
- Output: Generates
decompressed.txtas 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
.bmpfile in the directory. - Setup: Specify the image file in the code:
const char *inputFileName = "sample.bmp";
- Execution:
- Compile and run the
.cfile.
- Compile and run the
- Output:
- A
.bincompressed file. - A decompressed
.bmpfile version of the.binfile.
- A
- Sample File: Place the
.bmpfile in the directory. - Setup: Update the file name in the code:
const char *inputFile = "sample.bmp";
- Execution:
- Compile and run the
.cfile.
- Compile and run the
- Output:
- A
.rlecompressed file. - A decompressed
.bmpfile version of the.rlefile.
- A
- The "Sample Image" folder contains
.bmpimages for testing the image compression methods.
- For compatibility with the compression algorithms, images in formats such as
.png,.jpeg, or.bmpcan be standardized by opening the image in Microsoft Paint and saving it as a.bmpfile. 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!