Convert a GIF to PNG in JavaScript

When performing image format conversions, you don’t want to burn your valuable production time writing the complex code needed for the process. For example. If you have a GIF you need to transformed into a PNG, instead of building the operation out manually, we will demonstrate how you can use an API to automatically run the conversion in seconds.

We will begin the operation by installing the jQuery library:

bower install jquery

Then, we can call the conversion function with the following code:

var form = new FormData();
form.append("imageFile", fileInput.files[0], "file");
var settings = {
"url": "",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "multipart/form-data",
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
$.ajax(settings).done(function (response) {

The output will be your new PNG file! If you need to retrieve your API key, head over to the Cloudmersive website to register for a free account; this will give you access to 800 monthly calls across our library of APIs.