Recently, we published an article that demonstrates the GIF to JPG conversion process using GroupDocs.Conversion Cloud SDK for Java. Whereas, this blog post shows how to convert GIF to PNG in Node.js using GroupDocs.Conversion Cloud SDK for Node.js. You can leverage the REST APIs and Cloud SDKs exposed by GroupDocs.Conversion. However, you can build a GIF to PNG converter using this image conversion service. So, let’s start this guide and implement the functionality in a Node.js-based project that enables you to convert GIF to PNG programmatically.
We will cover the following points in this blog post:
GIF to PNG Conversion - API Installation
The installation process of this enterprise-level image conversion service is very simple and short. So, open the terminal/CMD, and run the following command to install GroupDocs.Conversion Cloud SDK for Node.js:
npm install groupdocs-conversion-cloud
Once the installation is completed, the next step is to obtain the API Credentials (Client ID, Client Secret). You can obtain these credentials from our API Cloud dashboard. Please visit this short tutorial in case you find any difficulty in obtaining API Credentials.
Convert GIF to PNG in Node.js
Before writing a code snippet, please be aware, that we have a source GIF file in our API Cloud dashboard which you can upload manually or programmatically by making a call to this UploadFile method.
The following steps demonstrate how to achieve GIF to PNG conversion programmatically:
- Obtain the groupdocs-conversion-cloud module into your Node.js project.
- Now, call the fromKeys function of the ConvertApi class and pass the API credentials (i.e. Client Secret, Client ID).
- Next, Instantiate an instance of the ConvertSettings class.
- Define the values to the properties of the ConvertSettings class such as storageName, filePath, outputPath, and format.
- Initialize an object of the ConvertDocumentRequest class with the instance of the ConvertSettings class.
- Invoke the convertDocument method to convert GIF to PNG in Node.js.
Copy and paste the following code sample into your main server file to build a GIF to PNG converter module for your business software:
The above code sample will generate a PNG file in the “test” folder in the API Cloud dashboard. You can download the generated file manually or programmatically by invoking this DownloadFile method. Thus, you can see the output in the image below:
Online GIF to PNG Converter
In addition to Cloud SDKs and REST APIs, GroupDocs.Conversion offers an online tool to convert GIF images to PNG online. This online tool is web-based and offers a very elegant and user-friendly user interface. Above all, it is free and requires no account creation or subscription.
We are ending this guide here with the hope that you found this article a solution to your problem. Moreover, we went through the code snippet and the steps to convert GIF to PNG in Node.js programmatically. In fact, you can also perform GIF to PNG conversion using our online tool. Similarly, you can visit the documentation and the GitHub repo to learn about the complete stack of features. Also, you can interact with our live APIs to experience the functionality and efficiency.
Finally, groupdocs.cloud is writing new articles. So, please stay in touch for the regular updates.
Help is Available
You can let us know about your questions or queries on our forum.
Frequently Asked Questions – FAQs
Can you convert a GIF to a PNG?
Please visit this link to learn how to convert GIF to PNG in Node.js programmatically.