We all know about compressed files like .zip, .rar, etc. If you are familiar with web, then you will know that the compressed files will help you to reduce the size of the documents, image files, etc. You will also be aware of the file transfer related things like, when transferring any compressed file, it will get transferred in less time when compared to non-compressed files. Have you ever thought about the logic behind this? Do you know about its working and what is file compression?
There is nothing magical. But it is the result of many hard working programmers out there. Let us see the two major types of compression that happen usually. It is lossless and lossy.
I have simplified the article for non-math people also. So if you are in need of any in depth details regarding the compression matters, then you can refer Wikipedia.
This compression method works with the principle of removing the redundancy. Let me explain this. Consider the below bricks which denotes our data,
There are two bricks in red color, five yellow colored bricks and three blue colored bricks. This is not the only way of representing the bricks. I can also represent them in the following way.
We have the same number of bricks – two in red, three in blue and five in yellow. But this arrangement consumes less space than the previous arrangement. The redundant bricks are represented by the numbers and hence it needs only three bricks to represent 10.
This will give you an overall image of the lossless compression. The repeated information is replaced with instructions to tell the computer about the repeated data.
Below is a simplified example for quick understanding,
The string aaaaaatttttttttt can be compressed as a6t10.
This is one of the methods of lossless compression as there are other mathematical tricks used to make it possible. But the only thing that you have to remember about the lossless compression is that the space is temporarily saved and with the compressed one, you can completely reconstruct the original file. If you know the numbers with which you can make an exact stack with the brick, then no information will be lost.
WinZip like programs works with this principle of lossless compression. When you compress or Zip any file, the redundant information is removed and if you decompress or UnZip, then it will be restored. No data will be lost.
In the case of image files, the .PNG type files use loss less compression technique. This is the reason for smaller size of the image files with lot of identical space. This identical information will be denoted using instructions.
These are some basic level information about loss less compression. If you need any more information, you can refer Wikipedia.
The lossy compression is used to compress the media type files like pictures, audio and video. For example, consider MP3. You know that you can store hundreds of songs in an Optical disc of capacity 700MB. This is only after compression as the sounds which humans can’t hear or barely hear will be removed as part of it. You will not be able to recognize any kind of sound loss by hearing the compressed audio. If you overdo it, then the audio will start to sound muddy as more information will be removed. You can store only 10 to 15 uncompressed audio songs in an optical disc while you can store hundreds of compressed songs in the same optical disc.
You can also go for lossy compression in JPEG images. The actual quality of the image will come down but when you are printing it, you will not be able to differentiate it. Even if you remove as much as redundant information, the picture will be look awesome.
If you go for repeated compression, then the image will be like the one bellow:
You can easily see the quality difference from the first to last photo when moving from left to right.
But before compression anything, do remember that you cannot get back the original quality picture or audio from a compressed file.
You can get more details here in Wikipedia about lossy compression.
At last, the compression technique helped many online file sharing sites, you tube, image sharing sites, etc. Without that, it is not possible to do lot of things so easily.
If I have missed any information, then please share with us.
Sindhu, a simple person with some real interest in software design, blogging, cooking and surfing net. She loves her life and enjoys every minute of it. More @ About Me