How Does File Compression Work? Lossy vs Lossless Explained
Compressing a file allows you to store and send files across the web at a fraction of their original file size. A file compression program searches for patterns within your data and stores the data in a much simpler format. If you’ve ever compressed a file, you may notice some differences in the quality from the original. For example, if you’ve texted an image to someone over the phone, the receiver may complain about how the image is illegible or “grainy.” Other times, there may be no issues with the quality of an uncompressed file.
There are two types of file compressions: lossy vs lossless.
- Lossy: File compression method that removes redundant data to significantly reduce the size of a file. Some data will be deleted, resulting in a smaller file when the data is uncompressed. PDF.Live’s PDF compression tool is a lossy-style compressor — compressing PDFs may change the resolution of the new PDF.
- Lossless: File compression method that doesn’t remove data during compression. The quality of the data won’t be affected but the resulting compressed file may not be much smaller than the original file. Zipping files is an example of lossless file compression — zipping a PDF does not change the integrity of the PDF.
How Does File Compression Work?
File compression software packages larger files into smaller parts and smooshes them together so they’re easier to “ship” online. That’s the layman’s way to explain it. If you’re a technophile who wants to learn more about how, exactly file compression works, we suggest this article on How Stuff Works, which explains how file compression tools look for patterns and redundancies to reduce files to smaller sizes. If you’re looking to understand the difference between lossy and lossless file compression, read on …
Lossy Compression Definition
The meaning of the word “lossy” is, simply, involving some loss of data.
A lossy compression program will significantly reduce the file size or quality of an original file. You may be wondering: Why would you ever want this? Sometimes an image file may come in a very high resolution that is unnecessary for how you’re using it. If you want to host an image on a website, for example, you don’t need the same quality as you’d need for printing the image. High-quality images may cause webpages to take longer to load, which can negatively impact your website’s performance in search results.
Also, if you want to send an image by email, it may be too large to attach to a message. As long as the recipient doesn’t need the file in its original size, you can compress it so it is smaller and easier to send by email, text message or other online file-sharing methods.
PDF.Live has an online PDF compression service that you can try out today. PDF.Live’s online PDF compressor is a lossy compression tool, but it reduces PDF file sizes with minimum impact on the information contained within.
What lossless means, in digital terms, is without loss of any data.
In a separate article, we cover ZIP files, which are a form of lossless compression. This means that any data compressed in a ZIP file can then be unzipped with no effect on the original data. ZIP files can be used on images, audio, text/text files, or a mix of many file types. For example, a software program that operates on your computer may be packaged within a single ZIP file that you download and then uncompress to install.
The process of compressing files is useful for saving space on your device’s hard drive as well as making files easier to share when uploading/downloading them. However, compressing a file can have potential downsides.
Lossy and Lossless – Which is Better?
The method that you use will be dependent on the type of data and how you plan to use the compressed file.
A JPEG image works well with lossy compression and most programs will automatically compress JPEGs using lossy compression. Compressing a JPEG with a lossy method will result in a slightly lower-quality image but a far smaller file size. Lossy compression may also damage a transparent background, or the legibility of images with a lot of text (such as converted PDFs!).
Example of lossy compression, before and after
On-screen, the before-and-after differences are barely detectable. Below, we used a 3rd party service called compressor.io to compress a JPEG of a closeup of a horse:
The lossy compressed version of this file is far smaller than the original, but the quality on-screen barely changes.
TIFF, BMP, and RAW images work far better with lossless file compression. The resulting compressed versions of these files won’t be much smaller than the original images, but the quality won’t diminish.
Example of lossless file compression, before and after
If you need an image to stay as high quality as possible, lossless file compression is probably better. Again, we used compressor.io to do lossless compression of the horse closeup:
However, the disc space that these files will take up on your system is almost exactly the same.
Below is the original file next to the compressed versions of the file. The top one uses lossy compression and reduces the file size by 90%. The second compression is lossless and compresses the file size by only 6%. You can see in the before-and-after comparisons below, that the difference is barely detectable.
Experiment with zipping, compressing, and uncompressing files to see what method works best for your needs. If you need to compress PDFs, PDF.Live has online PDF compression services that you can try out today. PDF.Live’s online PDF compressor reduces file sizes with minimum impact on the information contained within.