|
Consider the Number of Colors in
the Image
GIF and JPEG are the two most common
image formats on the WWW. JPEGs are capable of displaying images
that have millions of colors in their palette, while GIFs can only display
256 colors in an image. Therefore, JPEGs are particularly good for
displaying photographs and real world images, or perhaps even some
computer-generated images with complex color schemes. In the
table below, compare the JPEG on the left and the GIF on the right. If
your monitor is configured to display millions of colors, you should see a
significant difference. But if your monitor is configured to display
only 256 colors, there would be a negligible difference in quality (if any
at all) between the two images.
Photos and Images with
Complex Color Schemes
|
|
The
left graphic is
a jpeg/jpg image.
It displays a spectrum
of 16.7 million colors.
This particular image
has a file size of 6KB.
|
The
graphic
on the right
is a gif image.
It can display
a maximum spectrum
of only 256 colors.
This particular image
has a file size of 5KB.
|
|
Winner:
JPEG
JPEG is
very good at compressing a broad color spectrum.
GIF is
limited to only 256 colors.
Use Internet
Explorer 5.x or above and
click
here to compare GIFs and JPEGs
for displaying photos.
|
|
|
Graphics with Relatively
Simple Color Schemes
|
|
Both
these graphics have file sizes of about 1.5KB. But
for this JPEG to match the small file size of the GIF, it must
be compressed so much that there is a great deal of distortion.
Even with such high compression, this JPEG still uses a whopping
2709 colors in its palette. A JPEG is capable of clearly
displaying this image, but compression would have to be much
lower, resulting in a larger file size.
|
The
quality of this GIF would be the same whether its palette had 256
colors (GIF maximum), or just 5 colors. But the palette has been
deliberately reduced to only 5 colors to greatly reduce the file
size. The only way JPEG can compete with such a small file size
is to greatly compress the image, resulting in distortion. |
Winner:
GIF
As the
number of colors in an image's palette approaches or surpasses
a GIF's maximum of 256, JPEG, with its powerful compression
capabilities, becomes a wiser choice. But with a simple color
scheme, GIF provides a small file size without necessarily sacrificing
image clarity.
Use
Internet Explorer 5.x or above and
click
here to compare GIFs and JPEGs
for displaying graphics with simple color schemes.
|
Features
While JPEGs are
static images, GIFs can be animated. Also, you can designate one
color in a GIF as transparent, so that whatever is behind that color
shows through the image.
Animation
|
|
This JPEG
is set to a compression factor of 15, resulting in a clear image
with a file size of 6.9KB.
|
Because
this GIF has several layers to produce animation, the file size is
higher (16.6 KB) than if it were a static image.
|
| |
Transparency
|
|
To
make this JPEG appear transparent, we have to change the
background color of the image to exactly match the background
color of this table. Even so, it isn't true
transparency.
|
The
background color of this GIF is actually white, but white has been
selected as the transparent color for this image. Off-white
colors still appear because transparency applies only to one exact
color within a single image. |
|
When
the background of the table is changed, the JPEG no longer
simulates transparency. Once again, we'd have to change the
background color of the image to match the color of the table.
|
Once
the transparent color of a GIF is set, that color will always be
transparent, regardless of the table's background color.
That is, this GIF, and the one above it, are exactly the same
image. |
|
|