Animated GIF (Graphics Interchange Format) contains a number of image frames in a particular order within a single file. These frames are shown in a sequence to create the animation. There could be various use cases when you need to convert animated GIFs to other multi-page or raster image formats. The multi-page formats include TIFF as well as PDF whereas raster images could be PNG, JPG, BMP and etc. In this article, I’ll show you how to convert animated GIF images to TIFF, PDF, PNG. JPG, and BMP images programmatically using C#. The code samples provided in this article can easily be ported to VB.NET as well.
- Convert animated GIF to TIFF using C#
- Convert animated GIF to PDF using C#
- Extract and convert a frame of GIF to PNG using C#
- Convert a GIF frame to JPG using C#
- Convert a GIF frame to BMP using C#
C# GIF Converter API
Aspose.Imaging for .NET is a feature-rich API that supports manipulating a wide range vector or raster image formats including the animated GIFs. It allows converting animated GIF to other multi-page formats as well as raster images within the .NET application. You can install the API using NuGet Package Manager or download and reference its DLL file manually.
Convert Animated GIF to TIFF using C#
TIFF is a multi-page image format that keeps multiple images within a single file. Since the animated GIF also contains a sequence of frames, you can export all or selected frames to the TIFF format. In this conversion, each frame in GIF will be converted to a page in the TIFF image. The following are the steps to convert an animated GIF to TIFF format using Aspose.Imaging for .NET.
- Load a GIF image into Image object using Image.Load(String) method.
- Use the MultiPageOptions class to specify the range of frames you want to convert (optional).
- Convert GIF to TIFF using Image.Save(String, TiffOptions) method.
The following code sample shows how to convert GIF to TIFF using C#.
Convert Animated GIF to PDF using C#
In an animated GIF to PDF conversion, each frame of the GIF is converted into a separated page within the PDF. Just like GIF to TIFF, you can specify the range of frames you want to get in the converted PDF file. The following are the steps to convert an animated GIF to PDF.
- Create an instance of Image class and load the animated GIF file.
- Use the MultiPageOptions class to specify the range of frames (optional).
- Save the image as PDF using Image.Save(String, PdfOptions) method.
The following code sample shows how to convert animated GIF to PDF using C#.
Convert a GIF Frame to PNG, JPG, or BMP using C#
Since animated GIF contains a sequence of frames, you can extract the desired frame and convert it to raster images such as PNG, JPG, BMP, etc.
Convert GIF Frame to PNG using C#
The following are the steps to convert a GIF frame to a PNG image.
- Load the animated GIF image using Image.Load(String) method.
- Convert the GIF frame to PNG using Image.Save(String, PngOptions) method by specifying the frame number.
The following code sample shows how to convert a frame of an animated GIF to PNG using C#.
Convert GIF Frame to JPG using C#
Aspose.Imaging exposes JpegOptions class to set the options while converting a GIF frame to the JPG image. The following code sample shows how to convert a frame in GIF to JPG using C#.
Convert GIF Frame to BMP using C#
For GIF to BMP conversion, the API provides the BmpOptions class. The following code sample shows how to convert a GIF frame to BMP using C#.
Conclusion
In this article, you have learned how to convert an animated GIF to multipage formats such as TIFF and PDF using C#. Furthermore, we have seen how to extract a particular frame from the animated GIF and convert it to the PNG, JPG, or BMP images. You can explore more about Aspose.Imaging for .NET using the documentation.
See Also
Info: You may want to check out the FREE Text to GIF Converter Aspose recently developed.