/// <summary> /// Resizes the sample image and upload to Cloud Storage /// </summary> public void ResizeImageAndUploadToStorage() { Console.WriteLine("Resize an image and upload to cloud storage"); // Upload local image to Cloud Storage UploadSampleImageToCloud(); // Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Resize // for possible output formats var format = "gif"; int? newWidth = 100; int? newHeight = 150; var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var resizeImageRequest = new ResizeImageRequest( SampleImageFileName, newWidth, newHeight, format, folder, storage); Console.WriteLine( $"Call ResizeImage with params: new width:{newWidth}, new height:{newHeight}, format:{format}"); using (var updatedImage = ImagingApi.ResizeImage(resizeImageRequest)) { // Upload updated image to Cloud Storage UploadImageToCloud(GetModifiedSampleImageFileName(false, format), updatedImage); } Console.WriteLine(); }
public void ResizeImageTest(string formatExtension, params string[] additionalExportFormats) { string name = null; int? newWidth = 100; int? newHeight = 150; string folder = TempFolder; string storage = this.TestStorage; List <string> formatsToExport = new List <string>(this.BasicExportFormats); foreach (string additionalExportFormat in additionalExportFormats) { if (!formatsToExport.Contains(additionalExportFormat)) { formatsToExport.Add(additionalExportFormat); } } foreach (StorageFile inputFile in BasicInputTestFiles) { if (inputFile.Name.EndsWith(formatExtension)) { name = inputFile.Name; } else { continue; } foreach (string format in formatsToExport) { this.TestGetRequest( "ResizeImageTest", $"Input image: {name}; Output format: {format ?? "null"}; New width: {newWidth}; New height: {newHeight}", name, delegate { var request = new ResizeImageRequest(name, newWidth, newHeight, format, folder, storage); return(ImagingApi.ResizeImage(request)); }, delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream) { Assert.AreEqual(newWidth, resultProperties.Width); Assert.AreEqual(newHeight, resultProperties.Height); }, folder, storage); } } }