Tutorial GIF Compression

Discussion in 'Help' started by Daydreamer, Sep 4, 2011.

  1. Daydreamer

    Joined:
    Jan 29, 2007
    Gender:
    Male
    Location:
    Los Angeles
    137
    The filesize for the image below is 1,467 KB.

    [​IMG]

    And this image is 444 KB, three times smaller than the first one. In this tutorial I will show you how to get similar compression results.

    [​IMG]

    Both images contain the same number of frames, and I used the same optimization settings when compressing them. The difference in these two images is the number of changing pixels.

    GIF compression knows when a frame uses the same exact pixels as the frame before it, and compresses accordingly. Sprites compress well in GIFs because of the sheer number of repeating pixels.

    This GIF I made a few years ago is only 146 KB.

    [​IMG]

    To get the same result when compressing frames from a film is very difficult, because of grain and camera movement. Take a look at the first image again. What's moving in the picture? The girl, her refection, her shadow, and the hat.

    [​IMG]

    The rest can be masked out to show the first frame's background. This second image is the result of doing so.

    [​IMG]

    The method was applied to this GIF, it has a larger filesize than the second, but it has a lower resolution and number of frames. This is because there are more moving pixels.

    [​IMG]

    I will be using GIMP for masking. The principle is essentially the same in other advanced graphic editors.

    Open your frames in GIMP as layers, with the first frame starting at the bottom.

    [​IMG]

    Select moving elements in the second frame

    [​IMG]

    Then from the selection, we will create a mask.

    [​IMG]

    [​IMG]

    Make a copy of the frame before.

    [​IMG]

    And merge your current frame with it.

    [​IMG]

    After, it's rinse and repeat with the next frame, adding or subtracting from the selection to create masks. Do not subtract too much from the selection so that it won't show the elements of frame before it.

    When you are done, save your frames. They are now ready to be compressed by a GIF making program.
    This method of creating highly compressed GIFs by masking unmoving parts won't work in most cases, especially if you want to make a GIF with a lot of moving pixels, like rain or action scenes.​
     
  2. reptar REEEEEEEEEEEEEEEEEEEEEEEEEE

    Joined:
    Jan 30, 2007
    Gender:
    Female
    Location:
    czar casm
    896
    This is a method I too normally use to compress my GIFS although I never get the chance too since most things I gif have the camera move (I use brushes to do so, but I will try this out). I say this is a very good and informative tutorial.

    If you use this on the wrong scene it will look like this
    [​IMG]
    [​IMG]
    Trust me. More people do this.