We’ve been using RAR and ZIP files for a long time. Despite that, most people still aren’t sure why this compression method is so popular.
To answer that, we need to go back to 1986, when Phillip Katz invented the ZIP file. At first, he implemented it with the PKZip program for his own company, PKWare. The method proved so useful that it soon found its way within all operating systems.
So, how does file compression work? In simple terms, file compression allows you to transfer files that would take up too much time and bandwidth. Any time you access a RAR or ZIP file, you’re benefiting from file compression.
Want to know more about file compression? You’ve come to the right place!
How Does File Compression Work?
File compression is the act of reducing the size of files while maintaining their data. The compressed files are then much easier to transfer.
Though compression is useful, it’s not infinite. You can compress a file into a ZIP to reduce its size, but you can only do it once. That said, you can determine the size of the ZIP file by opting for one of the two main compression methods.
Also, check out how to transfer large files without compression.
Lossy compression reduces file size by taking out any unnecessary information. It’s most common in audio, video, and image formats, such as MP3 and JPEG.
For example, an MP3 file doesn’t contain all the audio from the original file. Instead, it removes some sounds that we can’t hear. That way, you get a lower size file with almost no real drawbacks.
A JPEG file removes any non-essential part of the image. In a picture containing the ocean, JPEG compression might reduce the water pixels to the same two or three shades of blue. The original picture likely uses many different shades.
The more you compress a file, the more noticeable the drop in quality will be. This is why many MP3 recordings on YouTube sound worse than you may remember.
When to Use Lossy Compression
The best time to use lossy compression is when a file contains more information than you need. A big RAW file looks great, but it’s wasted on Facebook.
Companies such as Netflix and Spotify use compression to great effect. That way, they can transfer massive amounts of information while preserving quality. This makes their operations far more efficient.
Keep in mind that saving in a lossy format often allows you to set the quality. For instance, most image editors come with a quality slider. If you save the image at 80-90%, you’ll drastically reduce the file size with little difference to the eye.
As the name implies, lossless compression doesn’t remove any information. Instead, it compresses a file by removing redundancy.
To illustrate this, imagine a file that contains this string of characters:
By using lossless compression, you can compress this string into the following form:
That way, you use 7 characters instead of 21 to represent the same data.
When to Use Lossless Compression
If you can’t remove any part of the original file, you’ll use lossless compression. This is the main idea behind how ZIP and RAR files work.
Any time you use a program executable in Windows to create a ZIP or RAR file, you’re using lossless compression. When you unzip the file, all the information will still be there. That’s why this is the most efficient way of storing certain types of files.
The only caveat with ZIP and RAR files is that you need a way to open them. On a Mac, for instance, opening a RAR archive with the default tools is impossible. Here’s how you can open .RAR files on a Mac.
The most common lossless formats are ZIP, FLAC for audio, and PNG for images. Lossless video formats are rare since the files take up so much space.
Lossy vs. Lossless
At this point, you should know that there’s no single “best” method of compression. Choosing between lossy and lossless will depend on your needs.
As a rule of thumb, you should use lossless compression if you want a perfect copy of the original file. If the imperfect copy is good enough, use lossy compression. In some cases, you may even want to use these two methods together.
For example, let’s say you want to digitize your old CD collection. To do that, you’ll need to rip your CD’s, which works best in a lossless FLAC format. That way, your copy on the computer will have the same quality as the one on the CD.
Now, what if you want to have those same files available on the go? After all, we all like having our favorite music on our phones. In this case, you likely won’t care about having perfect quality, so you can convert those FLAC files to MP3.
This is the best way to get a perfectly listenable audio file without overloading your phone. An MP3 file converted from the FLAC will be as good as if you’d compressed an MP3 file from the original CD.
Data Compression Conversions
As you can see, converting a lossless format to lossy is fine. The same applies when converting a lossless format to another lossless format.
However, converting a lossy format to lossless is a waste of space. Sure, you can convert a 4 MB MP3 file to a 40 MB FLAC file, but this won’t recover the data lost during the MP3 compression. The 40 MB file will sound exactly like the 4 MB file.
Converting one lossy format to another is also not the best approach. With each compression, the quality of the file will degrade further. After a few compressions, the file will end up being unusable.
More on File Compression
Hopefully, this article has shed some light on the question of, “How does file compression work?”
Keep in mind that this is just an overview of how compression works. The algorithms that decide which data gets removed during compression are far more complicated. If you’re interested in this topic, there are still plenty of things you can learn.
Want to know more about the importance of data compression? Interested in learning how to enable file and folder compression? Keep checking out our blog!
Leave a Reply