|Color, format, and file size have a
symbiotic relationship. Like issues of image size,
it is not necessary to know a lot about digital color to do your normal
editing business, but understanding color helps with a number of issues.
Color and Format: GIF, the most common image file
format, is usually used for solid colors and simple images, since it
uses a maximum of 256 colors. This does not mean that there are always 256
colors present in a GIF image, only that a pixel (see Size
for a discussion of pixels) can be only one of 256 possibilities. In fact,
there can be fewer, and the fewer the colors, the smaller the file size.
Black and white images can be made to be only those two colors (black and
white), making such files quite small. GIFs were the original image file
format on the Internet, and they do their reduction of size by simplifying
the image - primarily by simplifying color.
JPG (back) vs. GIF (front) showing gradient
JPG's, in contrast, reduce their file size by a
mathematical algorithm rather than through a simplified image, hence they
allow for more colors - 16 million. Again - this is the maximum, but fewer
are possible, and can sometimes reduce file size. Since GIF and JPG do the
business of building their images differently (see Image
Formats), a JPG and GIF of the same image with the same number of
colors will not be the same file size. Which will be bigger
will depend on the complexity of the image.
What does this mean in terms of appearance? It's most
noticeable in gradients - colors that smoothly transition from one shade
to another. The more colors available, the smother the transition. This is
why JPG's are better for photographs, because photographs are full of
subtle color transitions. If an image is created with blocks of
electronically-produced color, then uniformity of color through the image
is guaranteed, and no price is paid for a small color count.
GIF also has the possibility of including transparency.
In fact, you can choose any of the 256 colors available to a GIF as its
transparent color, although a white background is the most common. Below,
the wallpaper is set to yellow in the boxes to display the ability to
select transparency color in GIFs. Converting a JPG to a GIF for the
purpose of making a portion transparent is usually doomed to failure - the
conversion process may reduce color count, but adjacent pixels will still
usually be different colors, and the transparency will barely be
White background set to transparency
Red set to transparency