{"id":276,"date":"2023-04-11T06:09:35","date_gmt":"2023-04-11T06:09:35","guid":{"rendered":"https:\/\/dataprot.net\/?p=276"},"modified":"2023-05-06T05:52:11","modified_gmt":"2023-05-06T05:52:11","slug":"data-compression","status":"publish","type":"post","link":"https:\/\/dataprot.net\/guides\/data-compression\/","title":{"rendered":"Data Compression Explained"},"content":{"rendered":"\n
Have you ever needed to send a few hundred photos from your vacation by packing them into an archive? Maybe you remember ripping your CDs into MP3s in the days when the iPod was still a brand new gadget. Whatever the case may be, you probably remember how the resulting archive ended up being significantly smaller than what you\u2019ve started with. That\u2019s because you compressed those files.<\/p>\n\n\n\n
Data compression is almost as old as computers are. It\u2019s one of those innovations that really changed how we interact with media. We wouldn\u2019t be able to stream Netflix through a VPN, quickly send pictures to our friends, or even backup music onto our smartphones without it. If you\u2019ve ever wondered how it all works under the hood, this is the article for you.<\/p>\n\n\n\n
For the uninitiated, compression looks like some sort of wizardry. You just press a few buttons, and voila – you have a .zip or .rar file that\u2019s significantly smaller than the file(s) you started with. How does the computer \u201cknow\u201d how to pack all that data up without damaging anything?<\/p>\n\n\n\n
That\u2019s where algorithms come into play. Every data compression technique has a particular set of rules. For example, when text compression is initiated, the computer will take all of the gaps in the text and assign them a single byte. After that, it will pack the byte into a string that tells the decoder where to put everything back.<\/p>\n\n\n\n
Image compression works similarly. Depending on the algorithm, you may get a smaller file with visibly inferior image quality or something that\u2019s almost the same size and looks pretty much identical to the original.<\/p>\n\n\n\n
Compression works by either removing unnecessary data or gathering the same or similar bytes and giving them a new value, thus allowing the computer to reconstruct the original data.<\/p>\n\n\n\n
Two main types of compression are called lossy and lossless since one is smaller but compromises image or sound quality, while the other tends to be larger but keeps the file quality intact.<\/p>\n\n\n\n
Lossy compression produces smaller files by analyzing the original data and removing unnecessary bits. That can be adjacent pixels of similar color or unused frequencies in a song. When executed well, lossy compression produces good results that are very close to the original work.<\/p>\n\n\n\n
However, making the compression algorithm more aggressive causes significant data loss in the final product – a photo can look pixelated, you\u2019ll hear songs missing certain sounds, and videos will become a blocky mess.<\/p>\n\n\n\n
Lossless data compression produces much better results if you\u2019re willing to sacrifice storage space. It\u2019s also non-destructive in its process. Instead of outright removing same-value bytes, the algorithm counts them and replaces the block with a byte signifying the number of replaced blocks. The idea is to preserve the structure of the original file(s).<\/p>\n\n\n\n
This is how most archiving tools and formats work, which is why you get the original files when you unpack archives created this way. Lossless compression is used in situations where lossy compression would cause irreparable damage to files, such as executables. It is also popular with audiophiles looking to preserve the quality of their music recordings.<\/p>\n\n\n\n