Lossy compression is a type of data compression in which actual information is lost. This means that after reconstructing the data from the information available, one winds up with something less than was in the original file. Generally, the goal is to use lossy compression such that there is not much observable loss in the final product, while saving enormously on file size over lossless compression.
Lossless compression is a form of compression in which data files are split up into different chunks and reorganized to optimize them. This sort of compression very rarely saves much space, but it is ideal for transporting enormous files by breaking them into easier-to-handle pieces. Lossless compression is used when every bit of data is needed in the end product, often when transmitting a file to a designer. In the case of images, a lossless compression allows the designer to be sure that any data they may want to alter will be there, letting them create a final product before compressing the file further using a lossy compression. This is also true of sound files, where a sound mixer may need additional information, such as separate channels, that an end user will not require.
The easiest way to understand lossy compression is by taking an example, such as what happens when you copy a RAW data file from a digital camera to a computer. This RAW file may be as much as 30MB, and include all sorts of data about color channels, information about how the shot was taken, and a wide range of data for each individual pixel. The presence of all of this information in a lossless format means that when you import it into a photo editing program with the right capabilities, all of these things can be modified. It also means that the color fidelity for each pixel is as high as it can possibly be.
At some point, though, you will likely want to do something other than edit the photo. You may want to send it to a friend via email, or to upload it to an online site. You may simply want to archive it, and another hundred images, on your computer, and at a size of 30MB each a hundred pictures would take up a full 3GB of space. So to deal with this, you’ll compress the photo. Some forms of lossless compression might be able to reduce the file size a bit, without losing any photo fidelity, but ultimately you’ll still wind up with enormous images.
This is where a lossless compression technique, like JPEG or GIF, comes into play. Using one of these compression techniques, an algorithm takes control of your photo and figures out shortcuts to describe it to the computer. Blocks of color that are largely the same are mapped the same, reducing file sizes substantially and often losing nothing that can be perceived by the human eye.
At extremely high levels, a 30MB lossless image can be compressed down to about 3MB and still appear almost identical to the human eye. The same is true of other lossy compression models, such as MP3s for sound or WMV for video. Of course, if the file sizes are reduced too far, the shortcuts taken wind up making the resulting image, sound file, or video, quite a bit different from the original, and the end result is of noticeably lower quality.