Image Storage
The four most common file formats used are:
- TIF - Tagged Image File Format, uncompressed and compressed formats
- PNG - Portable Network Graphics, standardized compression
- JPG - Joint Photographic Experts Group, compressed format
- GIF - Graphics Interchange Format, compressed format dating back to CompuServe
in the 1980's
Compression comes in two forms: lossless and lossy. Lossless
compression loses none of the image information during compression and
decompression. Lossy compression as its name says removes some of the
original photographic detail. Lossy compression can reduce the size of image
files to a far greater extent than lossless compression.
JPG is a lossy technique that is designed to compress color and grayscale
continuous-tone images. The information discarded at lower levels of JPG compression is
designed to be information that the human eye cannot detect. Please note that lossy formats such as JPG may result in the loss of
additional detail each time you open and save a file. This can cause severe color
shifts and distortion (example). If the image format from your digital camera is
lossy then your master copy should be the original image ex the camera or an
immediate conversion to a lossless format.
The following table shows characteristics of each of these image formats:
| Format |
Color
Depth |
Compression |
Loss of
Detail on Saves |
Web |
| TIF |
variable |
lossless |
No |
No |
| PNG |
variable |
lossless |
No |
Yes |
| JPG |
24 |
- lossy - |
- Yes - |
Yes |
| GIF |
- 8 - |
lossless |
No |
Yes |
| Note: |
Conversion to GIF suffers from an
immediate loss of color depth from 16 million colors to 256. After that there
is no further loss. Use of dithering results in limited image degradation for
on-screen viewing. There is an example in the next section. |
The next table shows the suitability of each format to particular applications.
| |
Photographs |
Photographs + edges |
Line
art, Drawings and Captured Screens |
| Image Type |
Real world images in
24-bit color or 8-bit gray scale |
Real world images with
very sharp edges including text and lines |
Text, blocks of the
same color or lines and sharp edges |
| Preferred format
for Master Copy |
PNG or TIF |
PNG or TIF |
PNG or GIF or TIF |
| Master Copy ex Digital
Camera |
If the camera produces a lossy
format then the original image ex the camera or the immediate
conversion to a lossless format. |
If the camera produces a lossy
format then the original image ex the camera or the immediate
conversion to a lossless format. |
not applicable |
| > 24-bit color |
PNG or TIF |
PNG or TIF |
PNG or TIF |
| EXIF retention |
TIF or JPG |
TIF or JPG |
TIF or JPG |
| Greatest compression |
JPG (JPG may not be suitable for master
copy) |
PNG or GIF, GIF reduces colors to 256
but improves text, lines and edges |
PNG or GIF |
| Redistribution |
JPG |
PNG or GIF |
PNG or GIF |
| Internet |
JPG |
GIF |
GIF |
| Interchange compatability |
TIF (not LZW) |
TIF (not LZW) |
TIF (not LZW) |
| Worst selection |
GIF reduces colors to 256, and is
larger than 24 bit JPG |
JPG smears text, lines and
edges |
JPG adds smears to text, lines and
edges |
Note: TIF LZW has limited support as Unisys has a patent on the LZW compression
algorithm used by both GIF and TIF with LZW compression. Not all
companies choose to support it for this reason. It is a small loss as LZW is a
relatively inefficient algorithm when applied to real world images, see the LZW
compression results in the next section.
The images below illustrate the imperfections of JPG on text and edges.
 |
 |
 |
| PNG original 26Kb |
JPG 6Kb. Note the crazing like imperfections
around the text. |
GIF 12Kb |

The following table gives the sizes of various image formats for an original image
of 1830 x 1240 x 16 million colors.
| Format |
Lossless |
Size (Kb) |
| TIFF - uncompressed |
Yes |
7,942 |
| TIFF - LZW |
Yes |
6,650 |
| PNG |
Yes |
3,434 |
| JPG - minimum compression |
No |
1,478 |
| JPG - 80 |
No |
395 |
| GIF |
No |
1,801 |
Graphics images are often stored in a compressed format to save space on your hard
drive and to maximize the number of images that will fit on removable storage such as
CD-R.
See examples
of image size and quality degradation with increased compression.
The question was should you compress images? The answer is dependent on your
needs.
- While still manipulating images use a lossless compression format.
- If you want to retain EXIF information the only alternatives are TIF and
JPG.
- When archiving (e.g. to CD-R) you should create at least two copies. One copy
could be a lossy format for viewing and the other a lossless
master.
- If you don't need to retain a master copy (i.e. you are never going to
change the image again) then you could consider doing both your archives in JPG
format.

What is TIF file format?
TIF or TIFF is short for "Tagged Image File Format". It was designed
primarily for raster data interchange. Its main strengths are a highly flexible and
platform-independent format which is supported by numerous image processing
applications.
TIFF can contain multiple kind of picture formats, like uncompressed, LZW and Fax 3
& 4 formats. The header section of TIFF-file contains the information about the
image, like the color depth, color encoding and compression type. Because of the
flexibility, very different levels of image quality can be produced with TIFF. The
current version is TIFF 6.0. 
The Portable Network Graphics (PNG) format was designed to replace
the older and simpler GIF format and, to some extent, the much more complex TIFF
format.
For image editing PNG provides a useful format for the storage of
intermediate stages of editing. PNG's compression is fully lossless--and
since it supports up to 48-bit truecolor or 16-bit grayscale--saving, restoring and
re-saving an image will not degrade its quality. Unlike TIFF, the PNG specification
leaves no room for implementors to pick and choose what features they'll
support; the result is that a PNG image saved in one application is readable in any
other PNG-supporting application.
For the Web, PNG really has three main advantages over GIF:
variable transparency, cross-platform control of image brightness, and a method of
progressive display. PNG also compresses better than GIF in almost every case, but
the difference is generally only around 5% to 25%.
See http://www.libpng.org/pub/png/png.html
for more information.
What is JPG file format?
JPEG (pronounced "jay-peg") is a standardized image
compression mechanism. JPEG stands for Joint Photographic Experts Group, the original
name of the committee that wrote the standard.
JPEG compression is lossy, meaning that the decompressed image
isn't quite the same as the one you started with. JPEG is designed to exploit
known limitations of the human eye, notably the fact that small color changes are
perceived less accurately than small changes in brightness. Thus, JPEG is
intended for compressing images that will be looked at by humans. If you plan to
machine-analyze your images, the small errors introduced by JPEG may be a problem for
you, even if they are invisible to the eye.
JPEG compression is designed for compressing either 16 million color
(24 bit) or 256 gray scale images of natural, real-world scenes. It works well on
photographs, naturalistic artwork, and similar material; not so well on lettering,
simple cartoons, or line drawings.
A useful property of JPEG is that the degree of lossiness can be
varied by adjusting compression parameters. This means that you can trade off
file size against output image quality. Most JPEG compressors let you pick a file size
vs. image quality tradeoff by selecting a quality setting. The quality scale is
purely arbitrary; its not a percentage of anything.
For full-color images, the uncompressed data is normally 24
bits/pixel. The best known lossless compression methods can compress such
data about 2:1 on average. JPEG can typically achieve 10:1 to 20:1 compression
without visible loss, bringing the effective storage requirement down to 1 to 2
bits/pixel. 30:1 to 50:1 compression is possible with small to moderate defects,
while for very-low-quality purposes such as previews or archive indexes, 100:1
compression is quite feasible. An image compressed 100:1 with JPEG takes up the
same space as a full-color one-tenth-scale thumbnail image, yet it retains much more
detail than such a thumbnail.
JPEG compression is poor on:
-
large areas of pixels that are all exactly the same color
-
icons that use only a few colors
-
very sharp edges: a row of pure-black pixels adjacent to a row
of pure-white pixels, for example. Sharp edges tend to come out blurred
unless you use a very high quality setting.
-
small text that's only a few pixels high
-
plain black-and-white (two level) images
If your image contains sharp colored edges, you may notice slight
fuzziness or jaggedness around such edges no matter how high you make the quality
setting.
It would be nice if, having compressed an image with JPEG, you could
decompress it, manipulate it (crop off a border, say), and recompress it without any
further image degradation beyond what you lost initially.
Unfortunately THIS IS NOT THE CASE. In general, recompressing an
altered image loses more information. Hence it's important to minimize the
number of generations of JPEG compression between initial and final versions of an
image. See an
example of how bad this can be.
There are a few specialized operations that can be done on a JPEG file
without decompressing it, and thus without incurring the generational loss that
you'd normally get from loading and re-saving the image in a regular image
editor. In particular it is possible to do 90-degree rotations and flips
losslessly, if the image dimensions are a multiple of the file's block size
(typically 16x16, 16x8, or 8x8 pixels for color JPEGs). This is of importance as
many users of digital cameras would like to be able to rotate their images from
landscape to portrait format without incurring loss --- and practically all digicams
that produce JPEG files produce images of the right dimensions for these operations to
work. So software that can do lossless JPEG transforms has started to pop
up. But you do need special software; rotating the image in a regular image
editor won't be lossless.
It turns out that if you decompress and recompress an image at the same
quality setting first used, relatively little further degradation occurs. This means
that you can make local modifications to a JPEG image without material degradation of
other areas of the image. (The areas you change will still degrade,
however.) Counterintuitively, this works better the lower the quality
setting. But you must use *exactly* the same setting, or all bets are off.
Also, the decompressed image must be saved in a full-color format; if you
dosomethinglikeJPEG=>GIF=>JPEG, the color quantization step loses lots of
information. [Authors note: Our tests used the same
quality setting and still suffered extreme degradation.]
Unfortunately, cropping doesn't count as a local change! JPEG
processes the image in small blocks, and cropping usually moves the block boundaries,
so that the image looks completely different to JPEG. You can take advantage of
the low-degradation behavior if you are careful to crop the top and left margins only
by a multiple of the block size (typically 16 pixels), so that the remaining blocks
start in the same places. (True lossless cropping is possible under the
same restrictions about where to crop, but again this requires specialized
software.)
The bottom line is that JPEG is a useful format for compact storage and
transmission of images, but you don't want to use it as an intermediate format for
sequences of image manipulation steps. Use a lossless 24-bit format (PNG,
TIFF, etc) while working on the image, then JPEG it when you are ready to file it away
or send it out on the net. If you expect to edit your image again in the future,
keep a lossless master copy to work from. The JPEG you put up on your Web
site should be a derived copy, not your editing master.
The information here on the JPG format has been summarized from: http://www.faqs.org/faqs/jpeg-faq/ 
What is GIF file format?
GIF, 'Graphics Interchange Format' was introduced in the 1980s on CompuServe
to allow high-quality, high-resolution graphics to be displayed on a variety of
graphics hardware and was intended as an exchange and display mechanism for graphics
images. The rise of the Internet and in particular the web saw GIF usage
explode.
Saving a photographic image as GIF firstly achieves a 3:1 compression by a reduction
in color depth from 16 million colors to 256. A GIF graphic is stored as a sequence of
pixels with 256 color values from a image specific color palette. Dithering
reduces the visual impact of the reduction in number of colors. This raster data is
then compressed according to the LZW algorithm (Unisys patented).
GIF is potentially useful on those areas where JPEG compression is poor
and where you are looking for a file size that is significantly less than PNG, that is
for images having:
-
large areas of pixels that are all exactly the same color
-
icons that use only a few colors
-
very sharp edges: a row of pure-black pixels adjacent to a row
of pure-white pixels, for example.
-
small text that's only a few pixels high
-
plain black-and-white (two level) images
GIF does significantly better than JPEG on images with only a few distinct colors,
such as line drawings. Not only is GIF lossless for such images, but it often
compresses them more than JPEG can. For example, large areas of pixels that are all
exactly the same color are compressed very efficiently indeed by GIF. JPEG can't
squeeze such data as much as GIF does without introducing visible defects.
|