To Use GIF or use JPEG?

In order to view images on the internet, the graphics must be in one of two formats, GIF and JPEG. These two formats can be created using a graphics program like Photoshop. I will be explaining the difference between the two and when to use what.

GIF stands for Graphics Interchange Format and is in a lossless format. This means the graphics program which produces it simply squashes the original image down and does not care if any data is lost. When the compression happens, the program looks for similar colors and compresses them into a single color. Thus the maximum compression for a GIF depends on the amount of repetition in the image. For example, a picture with two colors will compress well, whereas pictures with many colors will not.

A drawback of the GIF format is the number of colors available for compression. The GIF palette only contains 256 colors or less. This makes GIF less favorite for images with many colors. A good example of a lousy compression would be with photographs. Pictures contain many colors and the GIF compression format will not make the image appealing.

JPEG, which stands for Joint Photographic Experts Group, on the other hand is a lossy compressio method. In other words, it saves space by throwing away parts of an image. The JPEG algorithm works in the following way. It first divides the image into squares. Then it uses a piece of mathematics called Discrete Cosine Transformation to turn the square of daya into a set of curves that make up the image. Next is where the lossy bit comes in. Depending on how much you want to compress the image, the algorithm will throw away the least significant part. Thus, you can instruct the program to cmopress the image by a desired amount. However, the lossy compression method can generate unwanted effects such as false color and blockiness.

Reasons to use GIFReasons to use JPEG
  • Transparent Images or Colors:
    Using a graphic program, you can assign one of the colors in your image to be transparent. This way, you can get let the background of your web page shine through your image.
  • Interlaced Pictures:
    These images will first load up very poorly. But after a few passes, the gets better and better. The benefit here is that the viewer will at least see something when the image is loading.
  • Images with few colors or Solid Blocks of Color:
    GIF is a good format is your images contain less than 256 colors. The file size is a lot smaller if you use a gif. Thus, your GIF image will load quicker for the viewer.



This is an example of a picture compressed using GIF

  • Big Images:
    If your image is big, then JPEG is the format to use. It will make the file size really small.
  • Pictures with more than 256 Colors:
    If your image is a photograph or a scanned image, it will be better to save it as a jpeg. Not only will you have a better quality image, the file size will be small than a gif of the same file.


This is an example of a scanned image which is saved as a JPEG

Go Back