How GIFs Work
Gifs compress images by representing horizontally repeating pixels something like "White 24, red 24" etc.
The following 4 images are exactly alike, except that two of the images are rotated 90 degrees, and that one of the vertical versions is saved as a gif, and the other as a jpg, and one of the horizontal versions is saved as a gif, and the other as a jpg. Notice that the gif compression for this type of picture makes the file size of the images much smaller than the jpg compression does, and that the gif image with horizontal stripes has a much smaller file size than the gif with vertical stripes. Both of the jpgs are pretty much the same size.
| vertical | horizontal | |
|---|---|---|
| gif | 2K | 0.5K |
| jpg | 9K | 9K |
In the vertical gif, the compression represents the colors for each row something like "red 20 white 20 red 20 white 20 red 20".
In the horizontal gif, the compression represents the colors of each row something like "red 400". You can see why the file size might be smaller!
On the other hand, if you had a photograph, each successive pixel might be slightly different from the last, so a picture of a cheek might read "beige 1,pinky-beige 1, light pink 1, little more pink 1, really pink1, etc". The file size could easily balloon into something huge when each single pixle must be represented individually. This is why, of course, the gif compression is so good for logos, cartoons, and other images with large areas of flat color, and not so good for photographs or images with gradients.
GIF - 2Kb |
JPG - 9Kb |
GIF - 0.5Kb
|

