Whether you’re dealing with images, music, or video files, it’s important to understand the difference between different types of formats and when to use them. Using the wrong format could ruin a file’s quality or make its file size unnecessarily large.
Some types of media file formats are “lossy” and some types are “lossless.” We’ll explain what these terms mean, the advantages of each type of file format, and why you should never convert lossy formats to lossless ones.
We use compression to make files smaller, allowing them to download faster and take up less storage space. For example, when you take a photo, your camera captures all the light it can get and puts together an image. If you save the image in RAW format, which keeps all the light data the camera’s sensor received, the image may be as large as 25 MB. (This depends on the resolution of the image – a camera with more megapixels will produce a larger image.)
If we’re just uploading these files to a social network or placing them on a website, we don’t want these image files to take up so much space. A photo gallery with RAW images could take up hundreds of megabytes of space. RAW formats may be used by professional photographers to keep image quality high during the editing process, but they’re not intended for the average person.
Instead, our camera or smartphone converts the image to a JPEG file. JPEG files are much, much smaller than RAW images. When you convert RAW to JPEG, some of the image data is “thrown out”, producing a much smaller file. The conversion process uses a compression algorithm that works well for photos, allowing them to look fairly good in spite of the compression. You may still see compression artifacts, depending on the quality setting.
Note that lossy formats generally have a setting that controls how lossy they are. For example, JPEG has a variable quality setting. Low quality makes a smaller JPEG image file, but the quality of the image is noticeably worse. Below is a close-up example of a very lossy JPEG – you can see various “compression artifacts.”
Lossless vs. Lossy Formats
We call RAW a “lossless” format because it preserves all of the file’s original data, while we call JPEG a “lossy” format because some data is lost when we convert an image to JPEG. However, these aren’t the only formats that are lossy and lossless.
- Images: RAW, BMP, and PNG are all lossless image formats. JPEG and GIF are lossy image formats.
- Audio: WAV, FLAC, and ALAC (Apple Lossless Audio Codec, used by iTunes) are all lossless audio formats. MP3, MP4, and OGG are lossy audio formats.
- Video: Few lossless video formats are in common consumer use, as they would result in video files taking up a huge amount of space. Common formats like H.264, MKV, and WMV are all lossy. H.264 can provide smaller files with higher qualities than previous generations of video codecs because it has a “smarter” algorithm that’s better at choosing the data to throw out.
Some of these lossless formats also provide compression. For example, a WAV file is a completely uncompressed audio file, and takes up quite a bit of space. FLAC and ALAC are both lossless types of audio files that contain the same data as a WAV file, but they use a form of compression to create smaller files. Formats like FLAC and ALAC don’t throw any data away – they keep all the data and compress it intelligently, like ZIP files do. However, they are still significantly larger in size than MP3 files, which throw much data away.
In the below image, the bottom version of the photo is compressed with a poor-quality lossy compression algorithm. It will be noticeably smaller in file size than the above image.
Image from Wikimedia Commons
Why You Should Never Convert Lossy to Lossless
When you convert a file from a lossless format to a lossy format – say, ripping an audio CD (a lossless format) to MP3 files (a lossy format) – you’re throwing away some of the data. The MP3 file is so much smaller because much of the original audio data has been lost.
If you converted the lossy MP3 file to a lossless FLAC file, you wouldn’t get any of that data back. You’d get a much larger FLAC file that’s only as good as the MP3 file you converted from. You can never get the lost data back. Think of it like taking a perfect copy of a photocopy – even if it was possible to create a perfect copy of a photocopy, you would still end up with a photocopy, which isn’t as good as the original document.
This is also why it’s a bad idea to convert lossy formats to other lossy formats. If you take an MP3 file (a lossy format) and convert it to OGG (another lossy format), more of the data will be thrown away. Think of this like taking a photocopy of a photocopy – each time you photocopy a photocopy, you lose data and the quality becomes worse.
Conversion from lossless formats to lossy formats works well, however. For example, if you rip an audio CD (lossless) to FLAC files (lossless), you’ll end up with files as good as the original audio CD. If you later converted those FLAC files to MP3 files – say, to shrink them down so more of them will fit on an MP3 player – you’ll end up with MP3 files that are as good as MP3 files ripped from an audio CD directly.
Which Should You Use?
When you should use lossless formats and when you should use lossy formats depends on what you’re using them for. If you want a perfect copy of your audio CD collection, you should rip them to lossless files. If you want a copy to listen to on your MP3 player and file size is more important, use a lossy format instead.
If you want to put a photo on the web, you should use a lossy format to reduce that photo’s size. (but keep a backup of the original lossless file) If you’re printing the photo professionally, you’ll probably want to use a lossless format during the editing process. (Note that, for screenshots, PNG is a lossless format that can create appropriately-sized, sharp screenshots out of the flat colors found on computer screens. However, PNG becomes much larger if it’s used for photos, which contain much more jumbled up colors from the real world.)
We can’t possibly cover all of the situations you’d choose a media file format for – just be aware of the trade-offs when selecting a file format.
For more guidance on which image file type to use and when, read What’s the Difference Between JPG, PNG, and GIF? Or, if you’re curious about all the available audio file formats, read HTG Explains: What Are the Differences Between All Those Audio Formats?
This article was inspired by a comment exchange on a website. One commenter was upset that a legitimate BitTorrent file full of free music from the SXSW festival was in MP3 format instead of FLAC format. In response, someone replied that they could just change the format from MP3 to FLAC. If you’ve read this article, you should now understand why that reply was so silly.
Chris Hoffman is a technology writer and all-around computer geek. He's as at home using the Linux terminal as he is digging into the Windows registry. Connect with him on Google+.
- Published 03/31/13