Click here to Skip to main content
12,509,899 members (50,911 online)
Click here to Skip to main content
Add your own
alternative version


115 bookmarked

NGif, Animated GIF Encoder for .NET

, 1 Sep 2005 CPOL
Rate this:
Please Sign up or sign in to vote.
Create animated GIF images using C#.

Sample Image - NGif.gif


Because .NET Framework can't create animated GIF images, NGif provides a way to create GIF animations in the .NET framework. It can create an animated GIF from several images and extract images from an animated GIF.

Using the code

/* create Gif */
//you should replace filepath
String [] imageFilePaths = new String[]{"c:\\01.png","c:\\02.png","c:\\03.png"}; 
String outputFilePath = "c:\\test.gif";
AnimatedGifEncoder e = new AnimatedGifEncoder();
e.Start( outputFilePath );
//-1:no repeat,0:always repeat
for (int i = 0, count = imageFilePaths.Length; i < count; i++ ) 
 e.AddFrame( Image.FromFile( imageFilePaths[i] ) );
/* extract Gif */
string outputPath = "c:\\";
GifDecoder gifDecoder = new GifDecoder();
gifDecoder.Read( "c:\\test.gif" );
for ( int i = 0, count = gifDecoder.GetFrameCount(); i < count; i++ ) 
 Image frame = gifDecoder.GetFrame( i ); // frame i
 frame.Save( outputPath + Guid.NewGuid().ToString() 
                       + ".png", ImageFormat.Png );

Points of Interest

Use Stream to replace BinaryWriter when you write a fixed-byte structured binary file.


  • 31 Aug 2005: Draft.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

China China
No Biography provided

You may also be interested in...


Comments and Discussions

QuestionA major BUG in this project Pin
Member 421131021-Apr-16 21:02
memberMember 421131021-Apr-16 21:02 
BugTranspraency Support Pin
Nofuzy10-Sep-15 8:37
memberNofuzy10-Sep-15 8:37 
QuestionSet Different Delay times Pin
Nofuzy21-Aug-15 15:04
memberNofuzy21-Aug-15 15:04 
AnswerRe: Set Different Delay times Pin
John Schroedl10-Sep-15 8:16
memberJohn Schroedl10-Sep-15 8:16 
QuestionNice but slow Pin
Andy Cartwright20-Aug-15 19:43
memberAndy Cartwright20-Aug-15 19:43 
SuggestionThis works, but there's a better and much faster library (Bumpkit) Pin
Member 112479846-Mar-15 0:59
memberMember 112479846-Mar-15 0:59 
GeneralMy vote of 1 Pin
Member 1007116316-Aug-14 2:37
memberMember 1007116316-Aug-14 2:37 
QuestionArithmetic operation resulted in an overflow. Pin
Joshua Galloway8-Aug-14 4:53
memberJoshua Galloway8-Aug-14 4:53 
QuestionGreat tool, saved me a lot of work! Pin
mingonn29-Jan-14 13:58
membermingonn29-Jan-14 13:58 
GeneralGreate Job :) Pin
Vinaymm12-Dec-13 0:51
memberVinaymm12-Dec-13 0:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160929.1 | Last Updated 1 Sep 2005
Article Copyright 2005 by gOODiDEA.NET
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid