Professional Documents
Culture Documents
COMPRESSION-DECOMPRESSION WEB
TOOL USING HUFFMAN CODING
MTE PROJECT SYNOPSIS
Algorithm Design and Analysis (ADA)
(CO-208)
BACHELOR OF TECHNOLOGY
IN
COMPUTER ENGINEERING
Submitted by: -
STUDENT’S DECLARATION
ACKNOWLEDGEMENT
“Projects not only help a student to learn but to grow as well”. We would like to
express my thanks and gratitude to the faculty at Delhi Technological
University for providing us with the opportunity to work on projects and in the
process learn new technologies and learn practical use of our skills. We express
my sincere thanks to our honourable Ms. Shikha Mam, subject Algorithm
design and Analysis, Delhi Technological University for his constant guidance
and support.
CONTENT
1) Introduction
2) Need of the project
3) Technology Used
i. ReactJs
ii. TailwindCSS
4) Concepts and Data structures used
i. Huffman Coding
ii. Min Heap and JavaScript Classes
5) Flow of the code
i. Home page and selection of type of file – image or text
ii. Selecting the option either to compress or decompress
iii. Downloading page along with the compression ratio
iv. Decompressing the file back into original form
5) Future Scope
6) GitHub Link
7) References
Introduction
Compression can be defined as reducing the size of the file. Compression
software works by replacing these repeating patterns with smaller pieces of
data, or code, that take up less room. Whereas Decompression is the process of
restoring compressed data to its original form. Data decompression is required
in almost all cases of compressed data, including lossy and lossless
compression. Decompression is considered important, as compressed data needs
to be restored back to standard state for usage.
This project aims at compressing and decompressing images and files stored in
our computer system at a particular destination location. We will be using the
Huffman coding for compressing the data and a custom algorithm for
decompressing the same data.
Technology Used
1) ReactJs
React (also known as React.js or ReactJS) is a free and open-source front-
end JavaScript library for building user interfaces based on UI components. It is
maintained by Meta (formerly Facebook) and a community of individual
developers and companies. React can be used as a base in the development
of single-page or mobile applications. However, ReactJs is only concerned with
state management and rendering that state to the DOM, so creating React
applications usually requires the use of additional libraries for routing, as well
as certain client-side functionality.
2) TailwindCSS
Tailwind CSS is basically a utility-first CSS framework for rapidly building
custom user interfaces. It is a highly customizable, low-level CSS framework
that gives you all of the building blocks you need to build bespoke designs
without any annoying opinionated styles you have to fight to override.
The beauty of this thing called tailwind is it doesn’t impose design specification
or how your site should look like, you simply bring tiny components together to
construct a user interface that is unique. What Tailwind simply does is take a
‘raw’ CSS file, processes this CSS file over a configuration file, and produces
an output.
1) Huffman Coding
Huffman coding is a lossless data compression algorithm. The idea is to assign
variable-length codes to input characters, lengths of the assigned codes are
based on the frequencies of corresponding characters. The most frequent
character gets the smallest code and the least frequent character gets the largest
code.
For decompressing the Huffman code, through which we convert the encoded
data into the Huffman tree and from the corresponding values, we convert back
into the original data.
Huffman (C)
1. n=|C|
2. Q ← C
3. for i=1 to n-1
4. do
5. z= allocate-Node ()
6. x= left[z]=Extract-Min(Q)
7. y= right[z] =Extract-Min(Q)
8. f [z]=f[x]+f[y]
9. Insert (Q, z)
10. return Extract-Min (Q)
3) JavaScript classes
A JavaScript class is a blueprint for creating objects. A class encapsulates data
and functions that manipulate data. Unlike other programming languages such
as Java and C #, JavaScript classes are syntactic sugar over the prototypal
inheritance. In other words, ES6 classes are just special functions.
In our project, we have used these classes for creating the min Heap. Also, we
created a custom JavaScript class named Codec, for compressing and
decompressing the text.
For the case of images, we are first converting the uploaded image into its
Base64 string and then, we are compressing the same and now it can be easily
shared in this format.
Flow of code
The flow of code is as follows: -
1) Home Page
As soon as start the web tool, we are open to the home page with a navbar
containing the options for the type of file which we want to compress or
decompress. User can select ‘compress File’ if he wants to compress text file
else ‘compress image’ if he wishes to compress an image of type
.png/.jpg/.jpeg.
We have named our web tool as ‘wecompress’. After selecting the format of
the file, user have to upload or drop the file which he wishes to compress or
decompress. After that, user has to click next.
If a user tried to decompress a file which has not been compressed before, then it
will generate an alert and redirect to home page.
3) Compression of file
If the user presses compress button, then the file will be compressed using
Huffman coding and user will directed to a 3rd page where file will be
automatically downloaded. Also, the screen will be showing the compression
ratio.
Here, we have uploaded a file of alibaba.txt having a size of 10.0 mb and after
the compression, the size reduces to 2.5 mb.
The above two screenshots show the compression in the file size.
3) Decompression of file
The compressed file is not in readable form and can be decompressed back into
original form using our same tool.
After decompression, if we open the properties of decompressed file, we get the
original form back.
Future Scope
Here, we have considered Huffman coding in which after compression files are
not readable. To make them readable, we have to decompress them. We can
extend our project in which we can compress the files keeping them readable on
the same hand. We can also connect our project to AI- powered OCR so that we
can compress the PDF also. We can also add features like audio and video
compression to our project.
GitHub Link
https://github.com/Shivam311201/Huffman-File-Compressor
References
[1] Rhen Anjerome Bedruz and Ana Riza F. Quiros, “Comparison of Huffman
Algorithm and Lempel-Ziv Algorithm for Audio, Image and Text
Compression”, IEEE International Conference Humanoid, Nanotechnology,
Information Technology Communication and Control, Environment and
Management (HNICEM). Philippines, 9-12 December, 2015.
[2] Haoqi Ren, “A data Compression Technique based on Reversed Leading
Bits Coding and Huffman Coding”, International Conference on
Communication and Networking, China, 2015.
[3] K. Ashok Babu and V. Satish Kumar, “Implementation of Data
Compression Using Huffman Coding”, International Conference on Methods
and Models in Computer Science, India, 2010