Convert GIF to PSD with NET REST API

In this simple topic, you’ll learn how to convert GIF to PSD with NET REST API. We will create a GIF to PSD converter with C# Low Code API by following the detailed steps mentioned in the following sections. The created application can be integrated with any .NET application supported in macOS, Windows, or Linux environments and conversion can be done for free.

Prerequisite

Steps to Convert GIF to PSD with NET REST API

  1. Set the Client ID and Client Secret for the API to convert GIF to PSD
  2. Create an instance of the ImagingAPI class with client credentials to perform GIF to PSD conversion
  3. Specify the source GIF and output PSD file names
  4. Load the source GIF file and upload it to cloud storage
  5. Create an instance of the ConvertImageRequest with input GIF file stream and output PSD format
  6. Call the ConvertImage method to convert GIF to PSD with NET REST API
  7. Save the rendered PSD file stream on the local disk

The brief steps above explain rendering the file type from GIF to PSD with C# Low Code API. We will commence the setup of the SDK by initializing the ImagingAPI class instance. We will then access the source GIF file using a FileStream from the disk and create a ConvertImageRequest class instance that will further be referred to do the conversion to a PSD using the ConvertImage() method.

Code for GIF to PSD Conversion in NET Low Code API

using Aspose.Imaging.Cloud.Sdk.Api;
using Aspose.Imaging.Cloud.Sdk.Model.Requests;
using Aspose.Imaging.Cloud.Sdk.Model;
using System;
using System.IO;
namespace Kb_Aspose.KB
{
public class GifToPsdConverter
{
public void GifToPsd()
{
var clientID = "Client ID";
var clientSecret = "Client Secret";
var apiBaseUrl = "https://api.aspose.cloud";
var localPath = "C:/Words/";
var gifToPsdImageApi = new ImagingApi(clientSecret, clientID, apiBaseUrl);
// Source and output file names
var inputFileName = "Source.gif";
var outputFileName = "GiftoPsd.psd";
var outputFormat = "psd";
var remoteFolder = null; // Input file is saved at the root of the storage
var remoteStorage = null; // remote cloud Storage name
try
{
// Upload the local image to Cloud Storage
var inpuFileStream = File.Open(localPath + '/' + inputFileName, FileMode.Open);
inpuFileStream.Position = 0;
var uploadGifFileRequest = new UploadFileRequest(inputFileName, inpuFileStream, null);
gifToPsdImageApi.UploadFile(uploadGifFileRequest);
var convertGifToPsdRequest = new ConvertImageRequest(inputFileName, outputFormat,
remoteFolder, remoteStorage);
var gifDataStream = gifToPsdImageApi.ConvertImage(convertGifToPsdRequest);
gifDataStream.Position = 0;
using (var fileStream = File.Create(localPath + outputFileName + "." + outputFormat))
{
gifDataStream.Seek(0, SeekOrigin.Begin);
gifDataStream.CopyTo(fileStream);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}

This crisp code example demonstrates how to convert GIF to PSD with C# Cloud API. After addressing the required pre-requisite steps, you have to give a path to load the source GIF image on the disk and by using the Aspose.Imaging REST API SDK completes the rendering to PSD. The PSD image file stream is obtained as a response after the conversion is completed and you can then save it locally on the disk.

In this article, we have covered to transform GIF to PSD with Cloud API. If you are interested in performing GIF to BMP conversion, refer to the article on how to Convert GIF to BMP with NET REST API.

 English