As we all know that the term compression  means compressing the data or reducing the volume of data . Right But what that mean ??  how compression actually Happens ? Before going to discuss this all sort questions let first discuss why we need compression..




data in binary format

so we  all know how much data we daily produced whether its a text, image ,video  , music . whatever be the data we produced we keep on sharing and storing this data  in our storage device and  there is limited capacity for our storage device to store this n number  of data right . and whenever we share  this n number  of  data over any network it takes n of time . larger the  amount of data greater the amount of time it gonna take right or you can say that  time it takes off in transferring the data from one place to another is directly proportional to the amount of data which we are transferring. so these are two major reason..

first one storage device, second one is time it take for transferring..  .So here comes the concept of compression. all the big tech companies uses compression like Facebook, whats-app , Instagram ,youtube and many more .


storage devices


For an example the image which we upload in whatsapp,instagram get compressed automatically , videos which upload on youtube.. get compressed and the main reason behind this is to reduce  the server cost and increase the transfer rate. there are lots of compression alogorithm  available in the market. which is used by this tech companies. 


So now lets discuss how compression process works

so to understand the concept of compression. lets go through this example ..

Most of time whenever we download any application from the internet we usually  encountered with these ZIP files. this zip file is compressed file which opened ( extract ) from winZip application to see the original file. the zip file is in compressed format but when extract with  the help of winZip it come back it  into its original size isn't it mysterious to you. definitely the question which arising in our head is how this zip file comeback to its original size right. from where did this extra bits adds up to it right . so we all know in order to get zip file back to its original state we are using an application that is winzip. with the the help winzip application we can compress and decompress the file .



social media platforms



so now the main point is what actually happen in compression. by which our file size get reduced. and what happen in decompression by which our file gets back to its original state (size ) from where did this extra bits added to it.

so most of the computer files are redudant they contain the same line of code over  again and again but at the different segment in the program file. so our winzip application uses compression algorithm to rid of these repitation of code again and again. 


inaugral speech



To understand  this concept  look at below example -


quote from John F. Kennedy's 1961 inaugural address

Ask not what your country can do for you -- ask what you can do for your country


so here in this quote we have 17 words , containing 61 letter , one dash , one period and 16 spaces between the words.if each one of this takes up one unit of memory in our storage device. we get total file size of  79 units.  lets look this quote again below.



  • "ask" occur two times.
  • "what" occur two times.
  • "your" occur two times.
  • "country" occur two times
  • "can" occur two times.
  • "do" occur two times.
  • "for" occur two times.
  • "you" occur two times.


so by looking above quote by this way we get rid of all the redundant words . so now we have " -- , ask , not , what , your , country , can , do , for , you " these are the 10 main essential thing which can reconstruct whole quote again


  1. ask
  2. what
  3. your
  4. country
  5. can
  6.  Do
  7. for
  8. you





Our sentence now reads: "1 not 2 3 4 5 6 7 8 -- 1 2 8 5 6 7 3 4"

see how we convert this quote in the above format. first fall we look for redundancy of words and then we then replace this words with a key Here key 1,2,3,4,5,6,7,8 which represent those words . but see this only takes up  34 units of memory . 



which is less than previous one . imagine this is only just a sentence not a speech so if we apply this to a speech. we can get compreesion level  much more than this. so this what actually compresssion look like it reduce our file size by get rid of  of those repeated code over and over in a program. and this type of  compression is called lossless compression because in this we are not losing actual information. because at the time decompreesion thesse all keys gonna to replace with those words and that reason we cannot  run a compressed  file . 

LZ77 and Huffman coding are two most popular compression algorithm. for compressing text related data. but we can also applies these for our binary data. but its compression rate is higher in text related data due the repeated words or patterns .



There are two types of compression :



a) Lossless compression


source : howtogeek website



The compression which we are discussing above is an example of lossless compreesion . because in this type of compreesion we are not  losing any actual information we get rid of all the repeated code at time  of compression . and when we got this compressed file we have to decompress it in order to see the information . and the whole repeated code once again added to it  at the time of decompression. it is most popular and usefull type of compression  because due to its reduced size it easier for us to transmit it over any network without compromising with the quality of data.


b) lossy compression



compression level


the lossy compression are those compression where we start losing actual information. the most famous example for this type of compression is this . when we upload any picture, video on whatsaapp , instagram  and youtube  you can easily see difference in them in the terms of quality of that video or image.

  so now lets talk about how image compression. 


all the major social platform uses compression in their their platform whether it is whatsapp, instagram , snapchat , facebook , twitter...

we know that images are made up of pixels right. and  the majority  factor which depend  upon the quality of picture is no of pixels inside that resolution. and we all know that  every pixel represents the color  so what happens in image compression is that compression algorithm  reduce the no of pixels . which almost represent the same color.  which reduced our file size aloat but ultimately it effects quality of  image .

for more detailed information : - image compression article