Skip to content

Instantly share code, notes, and snippets.

@aspose-cloud
Last active September 28, 2021 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-cloud/45a1d1e458722a777cf4019922813f8f to your computer and use it in GitHub Desktop.
Save aspose-cloud/45a1d1e458722a777cf4019922813f8f to your computer and use it in GitHub Desktop.
This Gist contains code snippets related to the conversion of ODG files to PSD format using Aspose.Imaging Cloud SDK for .NET
This Gist contains code snippets related to the conversion of ODG files to PSD format using Aspose.Imaging Cloud SDK for .NET
// Get ClientID from https://dashboard.aspose.cloud/
string clientSecret = "d757548a9f2558c39c2feebdf85b4c44";
string clientID = "4db2f826-bf9c-42e7-8b2a-8cbca2d15553";
// create ImagingApi instance
ImagingApi imagingApi= new ImagingApi( clientSecret,clientID,"https://api.aspose.cloud/");
// path of input ODG image
string imageFile = "file-example_PDF.odg";
// output file format
string format = "PSD";
// resultant file name
string resultantFile = "Converted.psd";
try
{
// load the file from local drive
using (var file = System.IO.File.OpenRead(@"C:\Users\shahbnay\Desktop\" + imageFile))
{
// create FileUploadRequest instance
var uploadFileRequest = new UploadFileRequest(imageFile, file);
// Upload image to Cloud Storage
imagingApi.UploadFile(uploadFileRequest);
}
// Create ConvertImageRequest
var response = new ConvertImageRequest(imageFile, format, null, null);
// initiate the conversion operation
Stream updatedImage = imagingApi.ConvertImage(response);
// print success message if conversion is successful
if (response != null && response.Equals("OK"))
{
Console.WriteLine("ODG successfully converted to PSD !");
Console.ReadKey();
}
// custom method to save resultant file on local system drive
saveToDisk(updatedImage, @"C:\Users\shahbnay\Desktop\" + resultantFile);
}catch (Exception ex)
{
Console.WriteLine("error:" + ex.Message + "\n" + ex.StackTrace);
}
// custom method to save the stream as File instance
static void saveToDisk(Stream responseStream, String resultantFile)
{
var fileStream = File.Create(resultantFile);
responseStream.Seek(0, SeekOrigin.Begin);
responseStream.CopyTo(fileStream);
fileStream.Close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment