1. Home
  2.   Openize.Animated gif
  3.   Openize.Animated-GIF-SDK for .NET

Openize.Animated-GIF-SDK for .NET

 
 

Create & Edit Animated GIFs in .NET with Openize.Animated-GIF

A lightweight C# library to generate and decode animated GIFs with precise control over frames, colors, and playback settings.

Openize.Animated-GIF for .NET is a lightweight, open-source .NET library designed for creating and manipulating animated GIFs. This C# port of the popular animated-gif-lib-for-java provides robust support for GIF encoding and decoding, offering features like advanced color quantization, transparency control, and frame management.

Installation is straightforward via NuGet, allowing developers to seamlessly integrate GIF creation and manipulation capabilities into their .NET applications. Openize.Animated-GIF empowers developers with tools to generate animated GIFs from image sequences, extract frames and metadata from existing GIFs, and fine-tune animation parameters such as frame delays, loop counts, and disposal methods.

Explore our GitHub repository to contribute, suggest improvements, and enhance this Open Source SDK: https://github.com/openize-com/openize-animated-gif-net

Previous Next

Getting Started with Openize.Animated-GIF for .NET

The recommended way to install Openize.Animated-GIF for .NET is using NuGet. Please use the following command for a smooth installation.

Installation

 dotnet add package Openize.Animated.GIF 

Or via NuGet Package Manager:

 Install-Package Openize.Animated.GIF 

Quick Start

The following code snippet demonstrates how to create an animated GIF and Reading an Animated GIF using Openize.Animated-GIF for .NET.

Create an Animated GIF via .NET SDK

 using Openize.Animated.GIF; using System.Drawing;
// Initialize the encoder
var encoder = new AnimatedGifEncoder();
encoder.Start("output.gif");

// Configure animation settings
encoder.SetDelay(500); // 500ms between frames
encoder.SetRepeat(0); // Loop infinitely

// Add frames
encoder.AddFrame(new Bitmap("frame1.png"));
encoder.AddFrame(new Bitmap("frame2.png"));

// Finish encoding
encoder.Finish();

Reading an Animated GIF

 // Initialize the decoder
var decoder = new GifDecoder();
decoder.Read("input.gif");

// Get information
int frameCount = decoder.GetFrameCount();
int loopCount = decoder.GetLoopCount();  // 0 = infinite

// Extract frames
for (int i = 0; i < frameCount; i++)
{
    Bitmap frame = decoder.GetFrame(i);
    frame.Save($"frame_{i}.png");
}

Advanced Options

 // Configure transparency
encoder.SetTransparent(Color.White, true);  // Exact match

// Set specific background color
encoder.SetBackground(Color.Black);

// Custom size (for oversized images)
encoder.SetSize(800, 600);