GIF or JPG image formats?

GIF is a compression scheme that will preserve dots and sharp boundary contrasts, as on text. When an image is cartoonish with a few colors (4, 16, 64), GIF compression can tremendously shrink the file size, without losing crispness, by reducing the GIF color palette from 256 to the smallest reasonable number of colors.

The GIF format is also used to drop out the background to make it transparent. The image can then be overlaid on a patterned or colored background. The JPG format does not support a transparent layer.

JPG compression is generally used with photographic images where there are thousands of minute color changes across the image and where all those colors need to be there for a smooth transition. The compression algorithm shrinks file sizes by averaging out and blending some colors, so the image will be fuzzier and color boundaries may blur some. The smoothing effect is generally desirable in photos.

JPG compression can greatly reduce the file size of large images, depending on the amount of compression that is applied.



Below are visual examples of the differences between GIF and JPG. Beside each image is a blowup of the details to show the pixels.

Images that should use the GIF format:


Icons, buttons, logos, banners, cutouts, text.

Look at these two examples of a text image saved with GIF compression and with JPG compression. The text is just a little crisper in the GIF image, while the JPG file is considerably larger. In the blowup, notice all the random dots that are now part of the JPG image as a result of color blending. Those dots are part of the reason the JPG file is so much larger, and they obviously don't enhance the image appearance.

2K GIF image (2-color)


17K JPG image (80% Quality)




Images that should use the JPG format:

Now look at a photographic image with some suble hue shifts or gradients. The GIF compression, even at its best quality, is blotchier and produces a larger file size than the JPG compression. In photographic images, the JPG color blending creates more desirable results and a smaller file size. Because the image is bland, the JPG compression scheme can also crunch it into a much smaller file than it could a busy image.

20K GIF image (256-color)


5K JPG image (80% Quality)