GIF and JPEG are two of the most popular formats for graphics files on the Internet. It is advisable to use JPEG for photos, GIF for animations, and PNG for other images needed for online use.
JPEG files are best for photographs. GIF files are appropriate for images that are animations. A limitation of GIF files is that they only support 256 colors.
JPEG is a "lossy" format and you can control the file size by tweaking the Quality parameter in most image editing software. This parameter controls the aggressiveness of lossy compression used in the file. Generally, files saved at 85-90% quality using tools like ImageOptim result in significantly reduced file sizes, at the cost of minor color and detail loss that is usually indistinguishable to the naked eye.
GIF files offer pretty good compression (better than JPEG) but they only support 256 colors. Experts recommend using PNG files instead of GIF for all non-animation applications.
GIF vs PNG
See the full GIF vs PNG comparison for more details.
The PNG format has several advantages over GIF:
- Better compression, resulting in reduced file size (typically 5 - 25% better)
- PNG supports variable transparency (alpha channels).
- PNG offers control of image brightness (via cross-platform gamma correction) and color correction.
- PNG supports two-dimensional interlacing (a method of progressive display) while GIF does not.