Free Support Forum -

How to convert animated gif to another image format in .NET?

I am working with GroupDocs.Conversion in conjunction with another web-based previewing technology. I have an animated gif that I would like to convert to a PNG so that it’s previewable in this web-based viewer control (it currently doesn’t support gifs)
I have c# code that I can use to determine if the image contains multiple frames (ie - is animated), but I was wondering if GroupDocs.Conversion could handle extracting the first frame from the animated gif, or if that was something I had to write myself.
Looking here:

I was able to successfully upload my animated gif, and the converted file I received is the first frame of the animated gif, but as a png, which is exactly what I want. Is that behavior native to GroupDocs.Conversion? or is that custom code that you wrote?


1 Like


You can convert an animated GIF file to another image (e.g. PNG). For example, converting (27.0 KB) GIF to PNG will give you this output.png (11.8 KB).

Yes, API will extract first frame and give you output just like this app
Given below is the code for such a type of conversion:

string outputFileTemplate = Path.Combine(@"D:/Samples/Output/", "Converted-page={0}.png");
SavePageStream getPageStream = page => new FileStream(string.Format(outputFileTemplate, page), FileMode.Create);
using(Converter converter = new Converter(@"D:/Samples/sample.gif"))
    ImageConvertOptions options = new ImageConvertOptions
        Format = ImageFileType.Png
    converter.Convert(getPageStream, options);

You can get further details in this documentation article and download API here.

fantastic. thank you so much!

1 Like


You are welcome.