Skip to content

Instantly share code, notes, and snippets.

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/5910fdfab9704199ec83a715ff8b065b to your computer and use it in GitHub Desktop.
Save aspose-cloud/5910fdfab9704199ec83a715ff8b065b to your computer and use it in GitHub Desktop.
The GIST contains .NET Examples of Aspose.Imaging REST APIs.
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void AddSearchImage()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
string imageId = "WaterMark.bmp";
string folder = null;
string storage = null;
// Input image
using (FileStream imageData = File.OpenRead(ImagingBase.PathToDataFiles + imageId))
{
AddSearchImageRequest request =
new AddSearchImageRequest(searchContextId, imageId, imageData, folder, storage);
this.ImagingApi.AddSearchImage(request);
}
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
protected void AddImageFeaturesToSearchContext(string storageSourcePath, bool isFolder = false)
{
var request = isFolder
? new CreateImageFeaturesRequest(this.SearchContextId, imageId: null, imagesFolder: storageSourcePath, storage: null)
: new CreateImageFeaturesRequest(this.SearchContextId, imageId: storageSourcePath, storage: null);
this.ImagingApi.CreateImageFeatures(request);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
this.CreateImageFeatures(ComparableImage, false, searchContextId);
this.CreateImageFeatures(ComparingImageSimilarLess15, false, searchContextId);
this.CreateImageFeatures(ComparingImageSimilarMore75, false, searchContextId);
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateImageTag()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
string tag = "MyTag";
string imageName = "aspose_logo.png";
string folder = null; // File will be saved at the root of the storage
string storage = null; // We are using default Cloud Storage
// Load tag image as a stream
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + imageName))
{
this.ImagingApi.CreateImageTag(
new CreateImageTagRequest(inputImageStream, searchContextId, tag, folder, storage));
}
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
The GIST contains .NET Examples of Aspose.Imaging REST APIs.
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CompareLoadedImageToImageInSearchContext()
{
string ComparableImage = "ComparableImage.jpg";
string ComparingImageSimilarLess15 = "ComparingImageSimilar15.jpg";
// Create new search context
string searchContextId = this.CreateImageSearch();
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + ComparableImage))
{
var uploadFileRequest = new UploadFileRequest(ComparableImage, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
this.CreateImageFeatures(ComparableImage, false, searchContextId);
FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + ComparingImageSimilarLess15);
SearchResultsSet searchResults = this.ImagingApi.CompareImages(
new CompareImagesRequest(searchContextId, ComparableImage, inputImageStream));
double? similarity = searchResults.Results[0].Similarity;
Console.WriteLine("Images Similarity: " + similarity.ToString());
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CompareTwoImagesInSearchContext()
{
string ComparableImage = "ComparableImage.jpg";
string ComparingImageSimilarMore75 = "ComparingImageSimilar75.jpg";
// Create new search context
string searchContextId = this.CreateImageSearch();
// Upload both images to Cloud Storage
string[] images = { ComparableImage, ComparingImageSimilarMore75 };
foreach (string imageName in images)
{
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + imageName))
{
var uploadFileRequest = new UploadFileRequest(imageName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
}
this.CreateImageFeatures(ComparableImage, false, searchContextId);
this.CreateImageFeatures(ComparingImageSimilarMore75, false, searchContextId);
// Compare two images
string folder = null; // Folder with image to process
string storage = null; // We are using default Cloud Storage
SearchResultsSet searchResults = this.ImagingApi.CompareImages(
new CompareImagesRequest(searchContextId, ComparableImage, null, ComparingImageSimilarMore75, folder, storage));
double? similarity = searchResults.Results[0].Similarity;
Console.WriteLine("Images Similarity: " + similarity.ToString());
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
string CreateImageSearch()
{
string detector = "akaze";
string matchingAlgorithm = "randomBinaryTree";
string folder = null; // File will be saved at the root of the storage
string storage = null; // We are using default Cloud Storage
CreateImageSearchRequest createSearchContextRequest = new CreateImageSearchRequest(detector,
matchingAlgorithm, folder, storage);
SearchContextStatus status = this.ImagingApi.CreateImageSearch(createSearchContextRequest);
return status.Id;
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CropImageFrameFromStorage()
{
String fileName = "Sample.tiff";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? frameId = 0; // Number of a frame
int? x = 10;
int? y = 10;
int? rectWidth = 200;
int? rectHeight = 300;
// Result will include just the specified frame
bool? saveOtherFrames = false;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
GetImageFrameRequest getImageFrameRequest = new GetImageFrameRequest(fileName, frameId, x: x, y: y,
rectWidth: rectWidth, rectHeight: rectHeight, saveOtherFrames: saveOtherFrames, folder: folder, storage: storage);
Stream imageFrame = this.ImagingApi.GetImageFrame(getImageFrameRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "SingleFrame_out.tiff"))
{
imageFrame.Seek(0, SeekOrigin.Begin);
imageFrame.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CropImageFromStorage()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "WaterMark.bmp";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Crop
// for possible output formats
string format = "jpg"; // Resulting image format.
int? x = 10;
int? y = 10;
int? width = 100;
int? height = 150;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
var request = new CropImageRequest(fileName, format, x, y, width, height, folder, storage);
Stream updatedImage = this.ImagingApi.CropImage(request);
// Save updated image to local storage
string outPath = "Watermark_out." + format;
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + outPath))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateCroppedImageFromRequestBody()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "WaterMark.bmp";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Crop
// for possible output formats
string format = "jpg"; // Resulting image format.
int? x = 10;
int? y = 10;
int? width = 100;
int? height = 150;
string storage = null; // We are using default Cloud Storage
string outPath = null; // Path to updated file (if this is empty, response contains streamed image)
var request = new CreateCroppedImageRequest(inputImageStream, format, x, y, width, height, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateCroppedImage(request);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Watermark_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void DeleteSearchImage()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
string imageId = "WaterMark.bmp";
string folder = null;
string storage = null;
DeleteSearchImageRequest request =
new DeleteSearchImageRequest(searchContextId, imageId, folder, storage);
this.ImagingApi.DeleteSearchImage(request);
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
protected void DeleteImageFeaturesFromSearchContext(string imageName)
{
DeleteImageFeaturesRequest deleteImageFeaturesRequest =
new DeleteImageFeaturesRequest(this.SearchContextId, imageId: imageName);
this.ImagingApi.DeleteImageFeatures(deleteImageFeaturesRequest);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
// Delete the search context
this.DeleteImageSearch(searchContextId);
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
protected void DeleteSearchContext(string searchContextId)
{
string folder = null; // File is saved at the root of the storage
string storage = null; // Default Cloud Storage is being used
DeleteImageSearchRequest deleteSearchContextRequest = new DeleteImageSearchRequest(searchContextId,
folder, storage);
this.ImagingApi.DeleteImageSearch(deleteSearchContextRequest);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void SaveImageAsFromStorage()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "WaterMark.bmp";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Export(SaveAs)
// for possible output formats
string format = "pdf";
string folder = null; // Input file is saved at the root of the storage
string storage = null; // Cloud Storage name
var request = new SaveImageAsRequest(fileName, format, folder, storage);
Stream updatedImage = this.ImagingApi.SaveImageAs(request);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Watermark_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateSavedImageAsFromRequestBody()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "WaterMark.bmp";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Export(SaveAs)
// for possible output formats
string format = "pdf";
string outPath = null; // Path to updated file (if this is empty, response contains streamed image)
string storage = null; // Cloud Storage name
var request = new CreateSavedImageAsRequest(inputImageStream, format, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateSavedImageAs(request);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Watermark_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ExtractImageFeatures()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
string fileName = "WaterMark.bmp";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Extract features from image without adding to search context
string folder = null; // Folder with image to process
string storage = null; // We are using default Cloud Storage
ExtractImageFeaturesRequest extractImageFeaturesRequest =
new ExtractImageFeaturesRequest(searchContextId, fileName, null, folder, storage);
ImageFeatures imageFeatures = this.ImagingApi.ExtractImageFeatures(extractImageFeaturesRequest);
Console.WriteLine(imageFeatures);
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void FindImageDuplicates()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
// Upload input images to Cloud Storage
string[] images = { ComparableImage, ComparingImageSimilarLess15, ComparingImageSimilarMore75 };
foreach (string imageName in images)
{
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + imageName))
{
var uploadFileRequest = new UploadFileRequest(imageName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
}
this.CreateImageFeatures(ComparableImage, false, searchContextId);
this.CreateImageFeatures(ComparingImageSimilarLess15, false, searchContextId);
this.CreateImageFeatures(ComparingImageSimilarMore75, false, searchContextId);
double? similarityThreshold = 80; // The similarity threshold
string folder = null; // Path to input files
string storage = null; // We are using default Cloud Storage
ImageDuplicatesSet imageDuplicatesSet = this.ImagingApi.FindImageDuplicates(
new FindImageDuplicatesRequest(searchContextId, similarityThreshold, folder, storage));
Console.WriteLine("Duplicates Count: " + imageDuplicatesSet.Duplicates.Count);
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
double? similarityThreshold = 80; // The similarity threshold
string folder = null; // Path to input files
string storage = null; // We are using default Cloud Storage
ImageDuplicatesSet imageDuplicatesSet = this.ImagingApi.FindImageDuplicates(
new FindImageDuplicatesRequest(searchContextId, similarityThreshold, folder, storage));
Console.WriteLine("Duplicates Count: " + imageDuplicatesSet.Duplicates.Count);
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void FindSimilarImages()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
string ImageToFind = "4.jpg";
string ImagesPath = @"FindSimilar\";
string findImageId = ImagesPath + ImageToFind;
double? similarityThreshold = 3; // The similarity threshold
int? maxCount = 3; // The maximum count
string folder = null; // Path to input files
string storage = null; // We are using default Cloud Storage
// Upload images to Cloud Storage
string[] images = { "1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg", "6.jpg", "7.jpg", "8.jpg",
"9.jpg", "10.jpg"};
foreach (string imageName in images)
{
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + ImagesPath + imageName))
{
var uploadFileRequest = new UploadFileRequest(ImagesPath + imageName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
}
this.CreateImageFeatures(ImagesPath.TrimEnd('\\'), true, searchContextId);
SearchResultsSet searchResultsSet = this.ImagingApi.FindSimilarImages(
new FindSimilarImagesRequest(searchContextId, similarityThreshold, maxCount, imageId: findImageId, folder: folder, storage: storage));
Console.WriteLine("Results Count: " + searchResultsSet.Results.Count);
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void FindSimilarImagesByTag()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
string ImageToFindByTag = "ComparingImageSimilar75.jpg";
string ImagesPath = @"FindSimilar\";
string fileName = ImageToFindByTag;
FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName);
this.CreateImageFeatures(ImagesPath.TrimEnd('\\'), true, searchContextId);
string tagName = "ImageTag";
double? similarityThreshold = 60;
int? maxCount = 5;
string folder = null; // Path to input files
string storage = null; // We are using default Cloud Storage
this.ImagingApi.CreateImageTag(
new CreateImageTagRequest(inputImageStream, searchContextId, tagName, folder, storage));
var tags = JsonConvert.SerializeObject(new[] { tagName});
SearchResultsSet searchResultsSet = this.ImagingApi.FindImagesByTags(
new FindImagesByTagsRequest(tags, searchContextId, similarityThreshold, maxCount, storage: storage));
// Process search results
foreach (SearchResult searchResult in searchResultsSet.Results)
{
Console.WriteLine("ImageName: " + searchResult.ImageId +
", Similarity: " + searchResult.Similarity);
}
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void GetImageFrameFromStorage()
{
String fileName = "Sample.tiff";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? frameId = 1; // Number of a frame
int? newWidth = 300;
int? newHeight = 450;
int? x = 10;
int? y = 10;
int? rectWidth = 200;
int? rectHeight = 300;
string rotateFlipMethod = "Rotate90FlipX";
// Result will include just the specified frame
bool? saveOtherFrames = false;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
GetImageFrameRequest getImageFrameRequest = new GetImageFrameRequest(fileName, frameId, newWidth, newHeight,
x, y, rectWidth, rectHeight, rotateFlipMethod, saveOtherFrames, folder, storage);
Stream imageFrame = this.ImagingApi.GetImageFrame(getImageFrameRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "SingleFrame_out.tiff"))
{
imageFrame.Seek(0, SeekOrigin.Begin);
imageFrame.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateImageFrameFromRequestBody()
{
string fileName = "Sample.tiff";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
int? frameId = 1;
int? newWidth = 300;
int? newHeight = 450;
int? x = 10;
int? y = 10;
int? rectWidth = 200;
int? rectHeight = 300;
string rotateFlipMethod = "Rotate90FlipX";
bool? saveOtherFrames = false;
string outPath = null; // Path to updated file (if this is empty, response contains streamed image).
string storage = null; // We are using default Cloud Storage
CreateImageFrameRequest createImageFrameRequest = new CreateImageFrameRequest(inputImageStream, frameId, newWidth,
newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, saveOtherFrames, outPath, storage);
Stream imageFrame = this.ImagingApi.CreateImageFrame(createImageFrameRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "SingleFrame_out.tiff"))
{
imageFrame.Seek(0, SeekOrigin.Begin);
imageFrame.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void GetImageFramePropertiesFromStorage()
{
String fileName = "Sample.tiff";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? frameId = 1; // Number of a frame
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
GetImageFramePropertiesRequest imageFramePropertiesRequest = new GetImageFramePropertiesRequest(fileName,
frameId, folder, storage);
ImagingResponse imagingResponse = this.ImagingApi.GetImageFrameProperties(imageFramePropertiesRequest);
Console.WriteLine("Height: " + imagingResponse.Height + "Width: " + imagingResponse.Width);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ExtractImageFramePropertiesFromRequestBody()
{
string fileName = "Sample.tiff";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
int? frameId = 1;
ExtractImageFramePropertiesRequest imageFramePropertiesRequest = new ExtractImageFramePropertiesRequest(inputImageStream,
frameId);
ImagingResponse imagingResponse = this.ImagingApi.ExtractImageFrameProperties(imageFramePropertiesRequest);
Console.WriteLine("Height: " + imagingResponse.Height + "Width: " + imagingResponse.Width);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
protected void GetImageFeaturesFromSearchContext(string imageName)
{
GetImageFeaturesRequest getImageFeaturesRequest =
new GetImageFeaturesRequest(this.SearchContextId, imageId: imageName);
ImageFeatures imageFeatures = this.ImagingApi.GetImageFeatures(getImageFeaturesRequest);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void GetSearchImage()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
string imageId = "WaterMark.bmp";
string folder = null;
string storage = null;
GetSearchImageRequest request =
new GetSearchImageRequest(searchContextId, imageId, folder, storage);
Stream retrievedImage = this.ImagingApi.GetSearchImage(request);
// Save retrieved image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Watermark_out.bmp"))
{
retrievedImage.Seek(0, SeekOrigin.Begin);
retrievedImage.CopyTo(fileStream);
}
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void GetAllImageFramesFromStorage()
{
String fileName = "Sample.tiff";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? frameId = 1; // Number of a frame
int? newWidth = 300;
int? newHeight = 450;
int? x = 10;
int? y = 10;
int? rectWidth = 200;
int? rectHeight = 300;
string rotateFlipMethod = "Rotate90FlipX";
// Result will include all other frames
bool? saveOtherFrames = true;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
GetImageFrameRequest getImageFrameRequest = new GetImageFrameRequest(fileName, frameId, newWidth, newHeight,
x, y, rectWidth, rectHeight, rotateFlipMethod, saveOtherFrames, folder, storage);
Stream imageFrame = this.ImagingApi.GetImageFrame(getImageFrameRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "OtherFrames_out.tiff"))
{
imageFrame.Seek(0, SeekOrigin.Begin);
imageFrame.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void GetImagePropertiesFromStorage()
{
string fileName = "Sample.tiff";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Get properties of an image
// Folder with image to process. The value is null because the file is saved at the root of the storage
string folder = null;
string storage = null; // We are using default Cloud Storage
GetImagePropertiesRequest getImagePropertiesRequest = new GetImagePropertiesRequest(fileName, folder,
storage);
ImagingResponse imagingResponse = this.ImagingApi.GetImageProperties(getImagePropertiesRequest);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ExtractImagePropertiesFromRequestBody()
{
string fileName = "Sample.tiff";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
ExtractImagePropertiesRequest imagePropertiesRequest = new ExtractImagePropertiesRequest(inputImageStream);
ImagingResponse imagingResponse = this.ImagingApi.ExtractImageProperties(imagePropertiesRequest);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
string GetImageSearchStatus(string searchContextId)
{
string folder = null; // File is saved at the root of the storage
string storage = null; // Default Cloud Storage is being used
GetImageSearchStatusRequest searchContextStatusRequest = new GetImageSearchStatusRequest(searchContextId,
folder, storage);
SearchContextStatus status = this.ImagingApi.GetImageSearchStatus(searchContextStatusRequest);
return status.SearchStatus;
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
class ImagingBase
{
protected const string MyAppKey = ""; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
protected const string MyAppSid = ""; // Get AppKey and AppSID from https://dashboard.aspose.cloud/
protected const string PathToDataFiles = @"..\..\..\..\TestData\";
// Aspose.Imaging API
protected ImagingApi ImagingApi;
public ImagingBase()
{
this.ImagingApi = new ImagingApi(MyAppKey, MyAppSid);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void AppendTiffFromStorage()
{
String fileName = "Sample.tiff"; // Original image file name
String appendFileName = "Memorandum.tif"; // Image file name to be appended to original one
// Upload original image file to cloud storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Upload file be appended to cloud storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + appendFileName))
{
var uploadFileRequest = new UploadFileRequest(appendFileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Update TIFF Image parameters according to fax parameters
String folder = null; // Input file is saved at the root of the storage
String storage = null; // We are using default Cloud Storage
AppendTiffRequest request = new AppendTiffRequest(fileName, appendFileName, storage, folder);
this.ImagingApi.AppendTiff(request);
// Download updated file to local storage
DownloadFileRequest downloadFileRequest = new DownloadFileRequest(fileName, storage, null);
Stream updatedImage = this.ImagingApi.DownloadFile(downloadFileRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.tiff"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ModifyEmfFromStorage()
{
string fileName = "Sample.emf";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
string bkColor = "gray";
int pageWidth = 300;
int pageHeigth = 300;
int borderX = 50;
int borderY = 50;
string format = "png";
// Specifies where additional parameters we do not support should be taken from.
// If this is true – they will be taken from default values for standard image,
// if it is false – they will be saved from current image. Default is false.
bool? fromScratch = null;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // As we are using default Cloud Storage
var request = new ModifyEmfRequest(fileName, bkColor, pageWidth, pageHeigth, borderX, borderY,
fromScratch, folder, storage, format);
Stream updatedImage = this.ImagingApi.ModifyEmf(request);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "SampleEMF_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateModifiedEmfFromRequestBody()
{
string fileName = "Sample.emf";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
string bkColor = "gray";
int pageWidth = 300;
int pageHeigth = 300;
int borderX = 50;
int borderY = 50;
string format = "png";
bool? fromScratch = null;
string outPath = null; // Path to updated file (if this is empty, response contains streamed image)
string storage = null; // As we are using default Cloud Storage
var request = new CreateModifiedEmfRequest(inputImageStream, bkColor, pageWidth, pageHeigth,
borderX, borderY, fromScratch, outPath, storage, format);
Stream updatedImage = this.ImagingApi.CreateModifiedEmf(request);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "SampleEMF_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ResizeImageFromStorage()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "Sample.psd";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Resize
// for possible output formats
string format = "gif";
int? newWidth = 100;
int? newHeight = 150;
string folder = null; // Folder with image to process.
string storage = null; // We are using default Cloud Storage
ResizeImageRequest resizeImageRequest = new ResizeImageRequest(fileName, format, newWidth,
newHeight, folder, storage);
Stream updatedImage = this.ImagingApi.ResizeImage(resizeImageRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateResizedImageFromRequestBody()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "Sample.psd";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Resize
// for possible output formats
string format = "gif";
int? newWidth = 100;
int? newHeight = 150;
string outPath = null; // Path to updated file (if this is empty, response contains streamed image).
string storage = null; // We are using default Cloud Storage
CreateResizedImageRequest createResizedImageRequest = new CreateResizedImageRequest(inputImageStream, format, newWidth,
newHeight, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateResizedImage(createResizedImageRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ResizeImageFrameFromStorage()
{
String fileName = "Sample.tiff";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? frameId = 0; // Number of a frame
int? newWidth = 300;
int? newHeight = 300;
// Result will include just the specified frame
bool? saveOtherFrames = false;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
GetImageFrameRequest getImageFrameRequest = new GetImageFrameRequest(fileName, frameId, newWidth, newHeight,
saveOtherFrames: saveOtherFrames, folder: folder, storage: storage);
Stream imageFrame = this.ImagingApi.GetImageFrame(getImageFrameRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "SingleFrame_out.tiff"))
{
imageFrame.Seek(0, SeekOrigin.Begin);
imageFrame.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void RotateFlipImageFromStorage()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "Sample.psd";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-RotateFlip
// for possible output formats
string format = "gif";
string method = "Rotate90FlipX"; // RotateFlip method
string folder = null; // Folder with image to process.
string storage = null; // We are using default Cloud Storage
RotateFlipImageRequest getImageRotateFlipRequest = new RotateFlipImageRequest(fileName, format,
method, folder, storage);
Stream updatedImage = this.ImagingApi.RotateFlipImage(getImageRotateFlipRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateRotateFlippedImageFromRequestBody()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "Sample.psd";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-RotateFlip
// for possible output formats
String format = "gif";
String method = "Rotate90FlipX"; // RotateFlip method
String outPath = null; // Path to updated file (if this is empty, response contains streamed image).
String storage = null; // We are using default Cloud Storage
CreateRotateFlippedImageRequest createRotateFlippedImageRequest = new CreateRotateFlippedImageRequest(inputImageStream, format,
method, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateRotateFlippedImage(createRotateFlippedImageRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void RotateFlipImageFrameFromStorage()
{
String fileName = "Sample.tiff";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? frameId = 0; // Number of a frame
string rotateFlipMethod = "Rotate90FlipX";
// Result will include just the specified frame
bool? saveOtherFrames = false;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
GetImageFrameRequest getImageFrameRequest = new GetImageFrameRequest(fileName, frameId,
rotateFlipMethod: rotateFlipMethod, saveOtherFrames: saveOtherFrames, folder: folder, storage: storage);
Stream imageFrame = this.ImagingApi.GetImageFrame(getImageFrameRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "SingleFrame_out.tiff"))
{
imageFrame.Seek(0, SeekOrigin.Begin);
imageFrame.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void UpdateSearchImage()
{
// Create new search context
string searchContextId = this.CreateImageSearch();
string imageId = "WaterMark.bmp";
string folder = null;
string storage = null;
// Input image
using (FileStream imageData = File.OpenRead(ImagingBase.PathToDataFiles + imageId))
{
UpdateSearchImageRequest request =
new UpdateSearchImageRequest(searchContextId, imageId, imageData, folder, storage);
this.ImagingApi.UpdateSearchImage(request);
}
// Delete the search context
this.DeleteImageSearch(searchContextId);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
protected void UpdateImageFeaturesInSearchContext(string imageName)
{
UpdateImageFeaturesRequest updateImageFeaturesRequest =
new UpdateImageFeaturesRequest(this.SearchContextId, imageId: imageName);
this.ImagingApi.UpdateImageFeatures(updateImageFeaturesRequest);
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void UpdateImageFromStorage()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "Sample.gif";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Update
// for possible output formats
string format = "pdf";
int? newWidth = 300;
int? newHeight = 450;
int? x = 10;
int? y = 10;
int? rectWidth = 200;
int? rectHeight = 300;
string rotateFlipMethod = "Rotate90FlipX";
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
UpdateImageRequest getImageUpdateRequest = new UpdateImageRequest(fileName, format, newWidth,
newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, folder, storage);
Stream updatedImage = this.ImagingApi.UpdateImage(getImageUpdateRequest); ;
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateUpdatedImageFromRequestBody()
{
// Input formats could be one of the following:
// BMP, GIF, DJVU, WMF, EMF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, DICOM, CDR, CMX, ODG, DNG and SVG
string fileName = "Sample.gif";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
// Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Update
// for possible output formats
string format = "pdf";
int? newWidth = 300;
int? newHeight = 450;
int? x = 10;
int? y = 10;
int? rectWidth = 200;
int? rectHeight = 300;
string rotateFlipMethod = "Rotate90FlipX";
string outPath = null; // Path to updated file (if this is empty, response contains streamed image)
string storage = null; // We are using default Cloud Storage
CreateUpdatedImageRequest postImageUpdateRequest = new CreateUpdatedImageRequest(inputImageStream, format, newWidth,
newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateUpdatedImage(postImageUpdateRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out." + format))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ModifyBmpFromStorage()
{
string fileName = "WaterMark.bmp";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? bitsPerPixel = 32;
int? horizontalResolution = 300;
int? verticalResolution = 300;
bool? fromScratch = null;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
var request = new ModifyBmpRequest(fileName, bitsPerPixel, horizontalResolution,
verticalResolution, fromScratch, folder, storage);
Stream updatedImage = this.ImagingApi.ModifyBmp(request);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Watermark_out.bmp"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateModifiedBmpFromRequestBody()
{
string fileName = "WaterMark.bmp";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
int? bitsPerPixel = 32;
int? horizontalResolution = 300;
int? verticalResolution = 300;
bool? fromScratch = null;
string outPath = null; // Path to updated file (if this is empty, response contains streamed image)
string storage = null; // We are using default Cloud Storage
var request = new CreateModifiedBmpRequest(inputImageStream, bitsPerPixel, horizontalResolution, verticalResolution, fromScratch, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateModifiedBmp(request);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Watermark_out.bmp"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ModifyGifFromStorage()
{
string fileName = "Sample.gif";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? backgroundColorIndex = 5;
int? colorResolution = 4;
bool? hasTrailer = true;
bool? interlaced = false;
bool? isPaletteSorted = true;
int? pixelAspectRatio = 4;
bool? fromScratch = null;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
ModifyGifRequest getImageGifRequest = new ModifyGifRequest(fileName, backgroundColorIndex,
colorResolution, hasTrailer, interlaced, isPaletteSorted,
pixelAspectRatio, fromScratch, folder, storage);
Stream updatedImage = this.ImagingApi.ModifyGif(getImageGifRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.gif"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateModifiedGifFromRequestBody()
{
string fileName = "Sample.gif";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
int? backgroundColorIndex = 5;
int? colorResolution = 4;
bool? hasTrailer = true;
bool? interlaced = false;
bool? isPaletteSorted = true;
int? pixelAspectRatio = 4;
bool? fromScratch = null;
string outPath = null;
string storage = null; // We are using default Cloud Storage
CreateModifiedGifRequest postImageGifRequest = new CreateModifiedGifRequest(inputImageStream, backgroundColorIndex,
colorResolution, hasTrailer, interlaced, isPaletteSorted, pixelAspectRatio,
fromScratch, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateModifiedGif(postImageGifRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.gif"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ModifyJpeg2000FromStorage()
{
string fileName = "Sample.jp2";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
string codec = "jp2";
string comment = "Aspose";
bool? fromScratch = null;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
ModifyJpeg2000Request getImageJpeg2000Request = new ModifyJpeg2000Request(fileName, comment, codec,
fromScratch, folder, storage);
Stream updatedImage = this.ImagingApi.ModifyJpeg2000(getImageJpeg2000Request);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.jp2"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateModifiedJpeg2000FromRequestBody()
{
string fileName = "Sample.jp2";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
string codec = "jp2";
string comment = "Aspose";
bool? fromScratch = null;
string outPath = null; // Path to updated file (if this is empty, response contains streamed image)
string storage = null; // We are using default Cloud Storage
CreateModifiedJpeg2000Request postImageJpeg2000Request = new CreateModifiedJpeg2000Request(inputImageStream, comment, codec,
fromScratch, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateModifiedJpeg2000(postImageJpeg2000Request);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.jp2"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ModifyJpegFromStorage()
{
string fileName = "aspose-logo.jpg";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? quality = 65;
string compressionType = "progressive";
bool? fromScratch = null;
string folder = null; // Folder with image to process
string storage = null; // We are using default Cloud Storage
ModifyJpegRequest modifyJpegRequest = new ModifyJpegRequest(fileName, quality, compressionType,
fromScratch, folder, storage);
Stream updatedImage = this.ImagingApi.ModifyJpeg(modifyJpegRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.jpg"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateModifiedJpegFromRequestBody()
{
string fileName = "aspose-logo.jpg";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
int? quality = 65;
string compressionType = "progressive";
bool? fromScratch = null;
string outPath = null; // Path to updated file (if this is empty, response contains streamed image)
string storage = null; // We are using default Cloud Storage
CreateModifiedJpegRequest modifiedJpgRequest = new CreateModifiedJpegRequest(inputImageStream, quality, compressionType,
fromScratch, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateModifiedJpeg(modifiedJpgRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.jpg"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ModifyPsdFromStorage()
{
string fileName = "Sample.psd";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
int? channelsCount = 3;
string compressionMethod = "raw";
bool? fromScratch = null;
string folder = null;
string storage = null; // We are using default Cloud Storage
ModifyPsdRequest modifyPsdRequest = new ModifyPsdRequest(fileName, channelsCount, compressionMethod,
fromScratch, folder, storage);
Stream updatedImage = this.ImagingApi.ModifyPsd(modifyPsdRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.psd"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateModifiedPsdFromRequestBody()
{
string fileName = "Sample.psd";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
int? channelsCount = 3;
string compressionMethod = "raw";
bool? fromScratch = null;
string outPath = null; // Path to updated file (if this is empty, response contains streamed image).
string storage = null; // We are using default Cloud Storage
CreateModifiedPsdRequest modifiedPsdRequest = new CreateModifiedPsdRequest(inputImageStream, channelsCount,
compressionMethod, fromScratch, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateModifiedPsd(modifiedPsdRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.psd"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ConvertTiffToFaxFromStorage()
{
String fileName = "Sample.tiff";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Update TIFF Image parameters according to fax parameters
String folder = null; // Input file is saved at the root of the storage
String storage = null; // We are using default Cloud Storage
ConvertTiffToFaxRequest getTiffToFaxRequest = new ConvertTiffToFaxRequest(fileName, storage, folder);
Stream updatedImage = this.ImagingApi.ConvertTiffToFax(getTiffToFaxRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.tiff"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ModifyTiffFromStorage()
{
string fileName = "Sample.tiff";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
// Update parameters of TIFF image
string compression = "adobedeflate";
string resolutionUnit = "inch";
int? bitDepth = 1;
double horizontalResolution = 150;
double verticalResolution = 150;
bool? fromScratch = null;
string folder = null; // Input file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
ModifyTiffRequest getImageTiffRequest = new ModifyTiffRequest(fileName, bitDepth, compression, resolutionUnit,
horizontalResolution, verticalResolution, fromScratch, folder, storage);
Stream updatedImage = this.ImagingApi.ModifyTiff(getImageTiffRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.tiff"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateModifiedTiffFromRequestBody()
{
string fileName = "Sample.tiff";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
string compression = "adobedeflate";
string resolutionUnit = "inch";
int? bitDepth = 1;
double horizontalResolution = 150;
double verticalResolution = 150;
bool? fromScratch = null;
string outPath = null;
string storage = null; // We are using default Cloud Storage
CreateModifiedTiffRequest postImageTiffRequest = new CreateModifiedTiffRequest(inputImageStream, bitDepth, compression,
resolutionUnit, horizontalResolution, verticalResolution, fromScratch, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateModifiedTiff(postImageTiffRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "Sample_out.tiff"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ModifyWebPFromStorage()
{
String fileName = "asposelogo.webp";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
bool? lossless = true;
int? quality = 90;
int? animLoopCount = 5;
string animBackgroundColor = "gray";
// Specifies where additional parameters we do not support should be taken from.
// If this is true – they will be taken from default values for standard image,
// if it is false – they will be saved from current image. Default is false.
bool? fromScratch = null;
string folder = null; // Folder with image to process. The value is null because the file is saved at the root of the storage
String storage = null; // We are using default Cloud Storage
ModifyWebPRequest getImageWebPRequest = new ModifyWebPRequest(fileName, lossless, quality,
animLoopCount, animBackgroundColor, fromScratch, folder, storage);
Stream updatedImage = this.ImagingApi.ModifyWebP(getImageWebPRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "asposelogo_out.webp"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateModifiedWebPFromRequestBody()
{
string fileName = "asposelogo.webp";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
bool? lossless = true;
int? quality = 90;
int? animLoopCount = 5;
string animBackgroundColor = "gray";
bool? fromScratch = null;
string outPath = null; // Path to updated file (if this is empty, response contains streamed image).
string storage = null; // We are using default Cloud Storage
CreateModifiedWebPRequest modifiedImageWebPRequest = new CreateModifiedWebPRequest(inputImageStream, lossless, quality,
animLoopCount, animBackgroundColor, fromScratch, outPath, storage);
Stream updatedImage = this.ImagingApi.CreateModifiedWebP(modifiedImageWebPRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "asposelogo_out.webp"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void ModifyWmfFromStorage()
{
string fileName = "Sample.wmf";
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
var uploadFileRequest = new UploadFileRequest(fileName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
string bkColor = "gray";
int? pageWidth = 300;
int? pageHeight = 300;
int? borderX = 50;
int? borderY = 50;
bool? fromScratch = null;
string folder = null; // Folder with image to process. The value is null because the file is saved at the root of the storage
string storage = null; // We are using default Cloud Storage
string exportFormat = "png";
ModifyWmfRequest getImageWmfRequest = new ModifyWmfRequest(fileName, bkColor, pageWidth, pageHeight,
borderX, borderY, fromScratch, folder,
storage, exportFormat);
Stream updatedImage = this.ImagingApi.ModifyWmf(getImageWmfRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "WMFToPNG_out.png"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
public void CreateModifiedWmfFromRequestBody()
{
string fileName = "Sample.wmf";
using (FileStream inputImageStream = File.OpenRead(ImagingBase.PathToDataFiles + fileName))
{
string bkColor = "gray";
int? pageWidth = 300;
int? pageHeight = 300;
int? borderX = 50;
int? borderY = 50;
bool? fromScratch = null;
string outPath = null; // Path to updated file (if this is empty, response contains streamed image).
string storage = null; // We are using default Cloud Storage
string exportFormat = "png";
CreateModifiedWmfRequest postImageWmfRequest = new CreateModifiedWmfRequest(inputImageStream, bkColor, pageWidth,
pageHeight, borderX, borderY, fromScratch, outPath,
storage, exportFormat);
Stream updatedImage = this.ImagingApi.CreateModifiedWmf(postImageWmfRequest);
// Save updated image to local storage
using (var fileStream = File.Create(ImagingBase.PathToDataFiles + "WMFToPNG_out.png"))
{
updatedImage.Seek(0, SeekOrigin.Begin);
updatedImage.CopyTo(fileStream);
}
}
}
// For complete examples and data files, please go to https://github.com/aspose-imaging-cloud/aspose-imaging-cloud-dotnet
string ComparableImage = "ComparableImage.jpg";
string ComparingImageSimilarLess15 = "ComparingImageSimilar15.jpg";
string ComparingImageSimilarMore75 = "ComparingImageSimilar75.jpg";
// Upload input images to Cloud Storage
string[] images = { ComparableImage, ComparingImageSimilarLess15, ComparingImageSimilarMore75 };
foreach (string imageName in images)
{
// Upload local image to Cloud Storage
using (FileStream localInputImage = File.OpenRead(ImagingBase.PathToDataFiles + imageName))
{
var uploadFileRequest = new UploadFileRequest(imageName, localInputImage);
FilesUploadResult result = this.ImagingApi.UploadFile(uploadFileRequest);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment