There are many different formats for storing images in computer files. Each format uses a different method for packing image pixels into files. Each format has its own pros, cons and best uses.
Formats can be categorized as either:
Lossy. Saving an image slightly degrades the image quality, in order to achieve a much smaller file size.
Lossless. Saving an image does not degrade the image quality, but files are much larger.
For digital cameras and photos on the Internet, this lossy format is by far the most popular. It is popular because it compresses images very efficiently, resulting in much smaller files than other formats.
Image quality is slightly degraded during compression, but JPEG does a remarkably good job of producing small image files with good image quality. So good that the degradation can be very hard to discern.
With JPEG, you can trade-off file size for image quality by changing the amount of compression. For example, you can compress aggressively and accept a lower image quality. Or you can compress gently and preserve almost all the original image quality. You can often recognize images that have been excessively compressed by their "halo" or "blocky" artifacts.
Digital cameras typically offer 2 or 3 levels of compression, with names such as Standard and Fine. Image editing programs let you to set any desired compression level, usually on a scale of zero to 100. Sometimes the control is called "quality" instead. High quality is the same as low compression, and vice versa.
Here's an example of how JPEG compression affects file size:
Unfortunately, JPEG compression level is not a good predictor of file size. Even with images having the same pixel dimensions, the file size can vary over a range of 5-to-1, depending on the amount of detail in the images. If you need to obtain a specific file size, this usually requires trail-and-error with every image. However, our JpegSizer program avoids this problem by automatically calculating what compression level will give the desired file size.
JPEG format provides a progressive* display option. It is the only format with wide support for storage of EXIF data such as camera settings.
Many people do not realize that the slight degradation caused by JPEG compression accumulates every time you open a file, make changes, and save it. You can minimize this effect by using a very low compression setting when you save files, such as 3 or 5 (or a very high quality setting such as 95 or 97).
To avoid this issue completely: convert your original image files into PNG or TIFF format; save all edited versions in the same format; then convert to JPEG as a last step before use. But see the above note about EXIF data.
Conclusion: JPEG format is ideal for achieving small file sizes with photographic images, and is universally supported by digital cameras, web browsers, and other computer programs. For icons and other line art, PNG and GIF formats are much better choices. More info.
This relatively new format is lossless, so image files are much larger than with JPEG format. However it does compress photo images better than old lossless formats such as TIFF. Support for PNG files is not universal, but has become widespread, including all newer web browsers.
PNG provides options such as transparency, interlacing* and GIF-style color palettes.
Conclusion: PNG is ideal when a lossless format is needed. For icons and line art, it is a viable alternative for the GIF format. For photographic images, it is viable when the large files can be accepted. More info.
This format is commonly classified as lossless, but it only supports 256 different colors. Photographic images have many more colors than this, so GIF format would be extremely lossy and image quality would be very poor.
GIF format is popular for icons and line art with limited color counts. It is often used to store animations, i.e. multiple frames displayed at a specified speed.
GIF format is widely supported and can be displayed by all web browsers.
Conclusion: GIF is ideal when a lossless format is needed for icons, line art or other images with no more than 256 colors. More info.
Some digital cameras will let you store photos in the lossless TIFF format. Images do not suffered any degradation at all, but files are gigantic. Memory cards and hard drives fill up much faster, and file transfer times are much longer.
TIFF format provides options to store images with various lossless compression techniques, but they don't compress photo images very much, or as well as PNG format. TIFF files are not used in web pages, because browsers can't display them.
Some digital cameras will let you store photos in this lossless format. Images are not degraded but files are even bigger than with TIFF format. RAW formats often differ from one camera manufacturer to another.
RAW files contain minimally processed data from a camera's image sensor, before the camera software carries out adjustments such as color balance, saturation and histograms. This means that RAW files are not generally suitable for distribution to anyone. They should first be processed using image editing software, so that any necessary adjustments are made.
Conclusion: RAW format is ideal when you want to bypass a camera's internal image processing, and apply your own processing later. More info.
* An interlaced or progressive format allows a web browser or other image viewer to display a large image file as soon as loading begins, with displayed image quality increasing as loading continues.