1. Technology

Optimizing GIF Images

Vertical Lines Create Larger GIFs


GIF images compress files using a row-based algorithm called LZW. While this compression is lossless, it has trouble compressing vertical lines in images to the same magnitude as horizontal lines.

To test this, I created a GIF with 4 horizontal lines. It was saved with the following specifics:

  • Index of 2 colors
  • No dithering
  • No transparency
  • No interlacing

I then rotated the image 90 degrees and saved it again with the same specifications.

GIF File Sizes

The horizontal image was 391bytes, while the vertical was 1.23KB -- 3 times larger. The only difference was the rotation of the stripes.

The diagonal striped image in this gallery was created using the same base file, but I can't guarantee that there is the same amount of red color in the image. Even so, the image was 1.36KB larger than the horizontal image.

Optimizing GIF Images

If you want to optimize GIF images, you should minimize the amount of vertical lines in the image, in favor of horizontal.

Images 1-3 of 3
Horizontal Lines in a GIF - File Size: 391bytesHorizontal Lines in a GIFVertical Lines in a GIF - File Size: 1.23KBVertical Lines in a GIFDiagonal Lines in a GIF - File Size: 1.37KBDiagonal Lines in a GIF
More Optimzing GIF Images
  1. About.com
  2. Technology
  3. Web Design / HTML
  4. Web Design
  5. Graphics
  6. Optimizing Images
  7. Optimizing GIF Images - Tricks to Optimizing GIF Images

©2014 About.com. All rights reserved.