GifMotion by Warren Galyen

<PackageReference Include="GifMotion" Version="1.0.4" />

 Extensions

public static class Extensions
using System.Drawing; using System.Drawing.Imaging; using System.IO; namespace GifMotion { public static class Extensions { public static void SaveGif(this Image img, Stream stream, GIFQuality quality) { Quantizer quantizer; switch (quality) { case GIFQuality.Default: img.Save(stream, ImageFormat.Gif); return; case GIFQuality.Grayscale: quantizer = new GrayscaleQuantizer(); break; case GIFQuality.Bit4: quantizer = new OctreeQuantizer(15, 4); break; default: quantizer = new OctreeQuantizer(255, 4); break; } using (Bitmap bitmap = quantizer.Quantize(img)) bitmap.Save(stream, ImageFormat.Gif); } public static void Write(this FileStream stream, byte[] array) { stream.Write(array, 0, array.Length); } } }