Animated PNG (Portable Network Graphics) is an extension to PNG format to incorporate the animations. Just like animated GIFs, the APNG format is used to present the animations. An edge of APNG over GIF is, it supports 24-bit transparency whereas GIF supports only 8-bit. Furthermore, APNG provides a smoother animation as compared to an animated GIF. In this article, I’ll show you how to create the animated PNG (APNG) images from an image or multi-page Tiff and export APNG to animated GIF programmatically using C# (or VB.NET).

.NET API for Animated PNG Images

Aspose offers its .NET Imaging API to create or manipulate popular image formats including animated PNG using C# or VB.NET. We’ll leverage the capabilities of Aspose.Imaging for .NET to create or export animated PNG images. You can either download the API’s DLL or install it within your .NET application using NuGet.

PM> Install-Package Aspose.Imaging

Create Animated PNG from an Image using C#

Aspose.Imaging for .NET lets you create an animated PNG from a single-page image such as PNG by setting the custom animation and frame duration. The following are the steps to perform this operation.

The following code sample shows how to create an animated PNG (APNG) from a PNG image using C#.

Create Animated PNG from Multi-Page Tiff using C#

You can also use a multi-page Tiff file to create the animated PNG by setting the desired frame time. The following are the steps to create animated PNG from a Tiff file.

The following code sample shows how to create animated PNG from a Tiff file using C#.

Source Tiff

Source Tiff

Animated PNG

TIFF to Animated PNG

Export Animated PNG to Animated GIF using C#

You can also export an animated PNG image to an equivalent animated GIF. The following are the steps to export APNG to GIF.

The following code sample shows how to export animated PNG to GIF using C#.

Source Animated PNG

Animated PNG Image

Animated GIF

Animated PNG to GIF C#

Conclusion

In this article, you have learned how to create an animated PNG from different sources using C#. The step by step guide and code samples demonstrated how to create animated PNG from single-page PNG and multi-page Tiff as well as export animated PNG to an animated GIF using C#. You can learn more about manipulating APNG images using the documentation of the API.

See Also