1

3

1.) 1" x 1"
square (3 bit)
2.) 0.5" x 2"
square (3 bit)
3.) 2" x 0.5"
square (3bit)

all =1 square inch total area

GIF Format and RLE

[ Although somewhat over simplified, here is an explanation of what Run Length Encoding (RLE) means, and how it effects the compression (file size) when using GIF file formats. ]

2

ALL three images are saved as 119 byte GIF files!

The shape of a graphic object has little effect on the size of the resultant GIF file. GIF compression is not SHAPE sensitive. So why is that? See examples to left.

A

GIF compression uses RLE (Run Length Encoding) to compress an image. Effectively RLE looks horizontally across a ROW of pixels in the image, and uses repetitive patterns to decrease file size.

Look at the decomposed graphic (A) to the left. A single line of the image is made up of 13 red pixels, 5 blue, 3 green and finally 5 more red. The total number of pixels is 26. Without compression it would take 26 bytes to store this particular line. One byte representing the color table look up value (CLUT) for each position.

See the non-compressed format to the left. This is the type of byte stream that could be used to describe the image.

RLE would look across the line and create a table of values that might look something like this:

13,180,5,97,3,121,5,180

(Assume that 180 was the CLUT value of RED, 97 of BLUE, and 121 that of GREEN.) The compressed file would then contain pairs of numbers, representing first the number of "identical pixels" to follow, and then the color of those pixels. ("How many pixels", "Color of pixels") See the compressed format example.

In the next four examples (yellow and maroon bars) the horizontal pattern is broken, and compare the file sizes for each. As the complexity of the change increases, so does the resultant file size. A 4x difference, top to bottom.
(examples 1-4)

In the next four vertical examples (also maroon and yellow), the complexity increases across the series, but in a vertical direction. Note the file sizes also increase, but far less than the previous case. Less than 1.5x difference.
(examples 5-8)

GIF files are less sensitive to row change, and more sensitive to column change.

( Please keep in mind that the RLE method is more complex than presented here, but the conceptual method is roughly as described. Close enough to make educated guesses as to file size outcomes based on geometry and fill factors. )

Non-compressed format:

180,180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 180, 97, 97, 97, 97, 97, 121, 121, 121, 180, 180, 180


26 byte values representing the colors in the line.

Compressed format:

13, 180, 5, 97, 3, 121, 5, 180

( 13 , 180 ) ( 5 , 97 ) ( 3 , 121 ) ( 5 , 180 )
(think of them as being paired ( #pix , color ) )

8 bytes of code representing the line of colors.

1

1- 89 bytes

2

2 - 128 bytes

3

3 - 211 bytes

4

4 - 373 bytes

5 6 7 8

5 - 100 bytes
6 - 128 bytes
7 - 138 bytes
8 - 149 bytes

Menu Bar