How file compression works and compression programs:
- Basically a compression program reduces the file size and then expand them back later to their exact original size.
- File compression programs simply get rid of the redundancy.
- Take a look at this quote for example:
"Ask not what your country can do for you -- ask what you can do for your country."
- The quote has 17 words, made up of 61 letters, 16 spaces, one dash and one period. If each letter, space or punctuation mark takes up one unit of memory, we get a total file size of 79 units. To get the file size down, we need to look for redundancies.
- "ask" appears two times.
- "what" appears two times.
- "your" appears two times.
- "country" appears two times.
- "can" appears two times.
- "do" appears two times.
- "for" appears two times.
- "you" appears two times.
- Compression programs create a dictionary like the one above and then write codes instead of characters or groups of them.
Practice: Using compression programs:
- So, if this is our dictionary:
- Our sentence now reads:
- "1 not 2 3 4 5 6 7 8 -- 1 2 8 5 6 7 3 4"
- The compression program posses this dictionary on your local computer and could transform this code back to understandable material when one extracts files.
Demonstrate the compression using several compression utilities like Winzip, Winrar and Winace and then check their file sizes.
Also check which file types do not compress so much and which do compress a lot.