How to Convert GIF to PNG in C#

How to Convert GIF to PNG in C#

Build an enterprise-level GIF to PNG converter using this .NET image library. Load the image files and convert them to other popular image file formats programmatically. Just a few lines of source code in C# give you rich features related to image conversions. In this blog post, we will implement how to convert GIF to PNG in C# and we will also describe the methods and their functionalities. So, be sure that you have set up .NET on your local machine.

The following sections will be covered in this blog post:

.NET image library installation

The installation procedure offers no difficulty rather it is very easy. Therefore, feel free to download the DLL or install this library by running the following command in the NuGet package manager.

Install-Package Aspose.Imaging

How to Convert GIF to PNG in C#

Let’s write some piece of 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 avail of a free temporary license to try the API without evaluation limitations.

Summing up

To conclude, this blog post has demonstrated the GIF to PNG conversion using a .NET image library. In addition, you have learned how to convert GIF to PNG in C# programmatically. However, this blog post will surely help you in building a GIF to PNG converter in C# for your business software. Finally, do not forget to visit the documentation to learn other cool 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