For those of you who loved to use graphics in your websites,
you have probably heard of GIF and JPEG. They are the 2 most
common file formats used for graphics. Naturally, there are
other types of formats such as PNG, BMP, TIFF, and many others.
Most browser recognize graphics in GIF and JPEG formats though,
and that's why they are popular and widely used. So when should
you use GIF and when should you use JPEG?
Both GIF and JPEG files are compressed. The GIF format uses
a lossless compression scheme which is optimized for images
with regions of solid color. (like sprites, transparent images,
cartoons). JPEG uses a lossy compression scheme which is optimized
for images with many mixed colors (like photographs).
GIF files only require additional size when the color of horizontally
adjacent pixels changes. In other words, a horizontal line
of a single color takes the same amount of space no matter
how long it is. This makes GIF format ideal for solid color
images like logos, cartoons, and text stored as graphics.
GIF is also the most common way to store transparent images.
JPEG files use a lossy compression technique (slightly adjusting
the colors) to give a visually similar image that takes less
space. You can choose how much compression (and color change)
you want. For natural, photographic, or multi-color images,
JPEG does a good job. But for images with regions of solid
color, opt for GIF formats instead. When in doubt, try both
formats and choose the one that gives the best image quality
for the lowest file size.