How to Convert GIF to PNG in C#

How to Convert GIF to PNG in C#

Build an enterprise‑level GIF to PNG converter with this .NET image library. Load images and convert them to popular formats programmatically. A few lines of C# code provide powerful conversion features. This post shows how to convert GIF to PNG in C# and explains the relevant methods. Ensure .NET is installed on your machine.

The following sections will be covered in this blog post:

.NET image library installation

Installation is straightforward. You can download the DLL or install the library via the NuGet package manager with this command:

Install-Package Aspose.Imaging

How to Convert GIF to PNG in C#

Let’s write some code to demonstrate the GIF to PNG conversion programmatically in C#.

You may follow the steps and the code snippet mentioned below:

  1. Invoke the Load method to load the GIF image from an existing directory.
  2. Set a value of the AutoAdjustPalette property indicating whether the automatic adjust palette.
  3. Set the background color by setting the value of the BackgroundColor property.
  4. Create an instance of the PngOptions class.
  5. Instantiate an object of the MultiPageOptions class and initialize it with the number of pages.
  6. Convert frame 1 of GIF to PNG by calling the Save method.

Copy & paste the following code into your main file to convert GIF to PNG in C#:

The output can be seen in the image below:

GIF to PNG converter C#

Get a Free License

You can get a free temporary license to try the API without limits.

Summing up

In summary, we demonstrated GIF to PNG conversion with a .NET image library and showed how to convert GIF to PNG in C# programmatically. This guide helps you build a GIF to PNG converter in C# for your applications. Visit the documentation for more methods.

Moreover, we suggest you follow our Getting Started guide.

Finally, conholdate.com is writing new blog posts. So, please stay in touch for regular updates.

Ask a question

You can let us know about your questions or queries on our forum.

FAQs

Can you convert GIF to PNG?

Yes, load the GIF image using this Load method and call the Save method to save the file in PNG format. Moreover, visit this link to get the code snippet.

See Also