ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Computers & Software

How Does File Compression Work?

Updated on April 27, 2010

Have you ever tried to compress a file with a size of only one byte? Open notepad, type one letter and save it as file.txt, then compress the file as, you will see the .zip file size is 123 bytes; then compress the file as .rar, you will see the .rar file size is 77. The ‘compressed’ file actually is much bigger than the original file. That means, .zip file format need 122 bytes for itself to record the compression information, while rar file format 76.

Now you open the .zip in the Notepad, among the jumbled texts, you can recognize the file name which occurs twice; PK at the beginning, and if you compress several files, ‘PK’ occurs again and again. That’s because the .zip format was originally created in 1989 by Phil Katz for PKZIP. A ZIP file has a central directory located at the end of the file. The directory stores a list of the names of the entries (files or directories, here we only have one file.) stored in the ZIP file, along with other metadata about the entry, and an offset into the ZIP file, pointing to the actual entry data.

Now open .rar file, you can recognize RAR at the beginning and a file name.

Enough experiment, now let see how file compression works in general.

Different types of flies require different compression techniques. One technique for compressing text is based on the use of a document-specific dictionary that contains only the words found in that file. Each word in the dictionary is indexed by a number, and the original document is encoded as a list of indices that represent those dictionary entries. For a medium-sized document, the space needed to store the dictionary and the index list will be less than the space needed to store the ASCII-text encoding of the original document. A very long text file that contains many instances of repeated words might be reduced by as much as 50-60% of its original size.

But it's not worth to 'compress' a very small file, you may get a compressed file bigger than original file.


    0 of 8192 characters used
    Post Comment

    • jim.sheng profile image

      Dalriada Books Ltd 5 years ago from UK

      mp3 itself is a kind of compression format which reduces the quality of sound that are considered to be out of the human hearing ability, for example some very high pitch noises.

      Image compression are similar, higher compression rate, less accurate are the images. The loss of fidelity are acceptable to human eyes. for example image colour may be reduced by compression, but imperceptible to human visual ability.

    • profile image

      Franklin 5 years ago


      then how does a non text file like video mp3 and images compressed...