How to resize an animated gif image using C#?

Solution 1:

Took me a while to find this, but finally found a solution:

Install Magick.NET via NuGet, license can be found here:
https://magick.codeplex.com/license

Example code:

var newWidth = 100;
using (var collection = new MagickImageCollection(new FileInfo(@"C:\test.gif")))
{
    collection.Coalesce();
    foreach (var image in collection)
    {
        image.Resize(newWidth, 0);
    }
    collection.Write(@"c:\resized.gif");
}

From my tests, this works with alpha channels and varying frame rates. Seems to be perfect!

Solution 2:

You need to loop through the frames in the animated GIF and resize each one.

May also want to take a look at GifLib.