Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aspose-cloud-kb/339477c0f9ac0067d47b03bc938b113b to your computer and use it in GitHub Desktop.
Save aspose-cloud-kb/339477c0f9ac0067d47b03bc938b113b to your computer and use it in GitHub Desktop.
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 JpgToTiffConverter
{
public void JpgToTiff()
{
var clientID = "Client ID";
var clientSecret = "Client Secret";
var apiBaseUrl = "https://api.aspose.cloud";
var localPath = "C:/Words/";
var jpgToTiffImageApi = new ImagingApi(clientSecret, clientID, apiBaseUrl);
// Source and output file names
var inputFileName = "Source.jpg";
var outputFileName = "JpgtoTiff.tiff";
var outputFormat = "tiff";
var remoteFolder = null; // source file is saved at the root of the storage
var remoteStorage = null; // remote cloud Storage place name
try
{
// Upload the local image to Cloud Storage
var inpuFileStream = File.Open(localPath + '/' + inputFileName, FileMode.Open);
inpuFileStream.Position = 0;
var uploadJpgFileRequest = new UploadFileRequest(inputFileName, inpuFileStream, null);
jpgToTiffImageApi.UploadFile(uploadJpgFileRequest);
var convertJpgToTiffRequest = new ConvertImageRequest(inputFileName, outputFormat,
remoteFolder, remoteStorage);
var tiffDataStream = jpgToTiffImageApi.ConvertImage(convertJpgToTiffRequest);
tiffDataStream.Position = 0;
using (var fileStream = File.Create(localPath + outputFileName + "." + outputFormat))
{
tiffDataStream.Seek(0, SeekOrigin.Begin);
tiffDataStream.CopyTo(fileStream);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment