/// <summary> /// Update parameters of existing WEBP image, and upload updated image to Cloud Storage. /// </summary> public void ModifyWebPAndUploadToStorage() { Console.WriteLine("Update parameters of a WEBP image and upload to cloud storage"); UploadSampleImageToCloud(); bool?lossless = true; int? quality = 90; int? animLoopCount = 5; var 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; var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var getImageWebPRequest = new ModifyWebPRequest(SampleImageFileName, lossless, quality, animLoopCount, animBackgroundColor, fromScratch, folder, storage); Console.WriteLine( $"Call ModifyWebP with params: lossless:{lossless}, quality:{quality}, anim loop count:{animLoopCount}, anim background color:{animBackgroundColor}"); using (var updatedImage = ImagingApi.ModifyWebP(getImageWebPRequest)) { UploadImageToCloud(GetModifiedSampleImageFileName(), updatedImage); } Console.WriteLine(); }
/// <summary> /// Update parameters of existing GIF image. The image is saved in the cloud. /// </summary> public void ModifyGifAndUploadToStorage() { Console.WriteLine("Update parameters of a GIF image and upload to cloud storage"); UploadSampleImageToCloud(); int? backgroundColorIndex = 5; int? colorResolution = 4; bool? hasTrailer = true; bool? interlaced = false; bool? isPaletteSorted = true; int? pixelAspectRatio = 4; bool? fromScratch = null; var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var getImageGifRequest = new ModifyGifRequest(SampleImageFileName, backgroundColorIndex, colorResolution, hasTrailer, interlaced, isPaletteSorted, pixelAspectRatio, fromScratch, folder, storage); Console.WriteLine( $"Call ModifyGif with params: background color index:{backgroundColorIndex}, color resolution:{colorResolution}, has trailer:{hasTrailer}, interlaced:{interlaced}, is palette sorted:{isPaletteSorted}, pixel aspect ratio:{pixelAspectRatio}"); using (var updatedImage = ImagingApi.ModifyGif(getImageGifRequest)) { UploadImageToCloud(GetModifiedSampleImageFileName(), updatedImage); } Console.WriteLine(); }
/// <summary> /// Update parameters of a BMP image. Image data is passed in a request stream. /// </summary> public void CreateModifiedBmpFromRequestBody() { Console.WriteLine("Update parameters of a BMP image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { 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); Console.WriteLine( $"Call CreateModifiedBmp with params: bits per pixel:{bitsPerPixel}, horizontal resolution:{horizontalResolution}, vertical resolution:{verticalResolution}"); using (var updatedImage = ImagingApi.CreateModifiedBmp(request)) { // Save updated image to local storage SaveUpdatedSampleImageToOutput(updatedImage, true); } } Console.WriteLine(); }
/// <summary> /// Perform scaling, cropping and flipping of an existing image in a single request. And upload updated image to Cloud /// Storage. /// </summary> public void UpdateImageAndUploadToStorage() { Console.WriteLine("Update parameters of an image and upload to cloud storage"); UploadSampleImageToCloud(); // Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Update // for possible output formats var format = "pdf"; int? newWidth = 300; int? newHeight = 450; int? x = 10; int? y = 10; int? rectWidth = 200; int? rectHeight = 300; var rotateFlipMethod = "Rotate90FlipX"; var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var getImageUpdateRequest = new UpdateImageRequest(SampleImageFileName, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, format, folder, storage); Console.WriteLine( $"Call UpdateImage with params: new width:{newWidth}, new height:{newHeight}, x:{x}, y:{y}, rect width:{rectWidth}, rectHeight:{rectHeight}, rotate/flip method:{rotateFlipMethod}, format:{format}"); using (var updatedImage = ImagingApi.UpdateImage(getImageUpdateRequest)) { UploadImageToCloud(GetModifiedSampleImageFileName(), updatedImage); } Console.WriteLine(); }
public AsposeImagingCloudApiService(IConfiguration config) { string ClientId = config["AsposeImagingUserData:ClientId"]; string ClientSecret = config["AsposeImagingUserData:ClientSecret"]; ImagingCloudApi = new ImagingApi(clientSecret: ClientSecret, clientId: ClientId); }
/// <summary> /// Applies filtering effect to an image and upload updated image to Cloud Storage. /// </summary> public void FilterImageAndUploadToStorage() { Console.WriteLine("Apply filtering effect to an image and upload to cloud storage"); UploadSampleImageToCloud(); var filterType = "GaussianBlur"; var filterProperties = new GaussianBlurFilterProperties { Radius = 4, Sigma = 1.1 }; var format = "bmp"; var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var filterEffectRequest = new FilterEffectImageRequest(SampleImageFileName, filterType, filterProperties, format, folder, storage); Console.WriteLine( $"Call FilterEffectImage with params: filter type:{filterType}, radius: {filterProperties.Radius}, sigma: {filterProperties.Sigma} format:{format}"); using (var updatedImage = ImagingApi.FilterEffectImage(filterEffectRequest)) { UploadImageToCloud(GetModifiedSampleImageFileName(false, format), updatedImage); } Console.WriteLine(); }
public void CreateModifiedJpegTest(bool saveResultToStorage) { string name = "test.jpg"; int quality = 65; string compressionType = "progressive"; bool? fromScratch = null; string outName = $"{name}_specific.jpg"; string folder = TempFolder; string storage = this.TestStorage; this.TestPostRequest( "CreateModifiedJpegTest", saveResultToStorage, $"Input image: {name}; Quality: {quality}; Compression type: {compressionType}", name, outName, delegate(Stream inputStream, string outPath) { var request = new CreateModifiedJpegRequest(inputStream, quality, compressionType, fromScratch, outPath, storage); return(ImagingApi.CreateModifiedJpeg(request)); }, delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream) { Assert.NotNull(resultProperties.JpegProperties); Assert.NotNull(originalProperties.JpegProperties); Assert.AreEqual(originalProperties.Width, resultProperties.Width); Assert.AreEqual(originalProperties.Height, resultProperties.Height); }, folder, storage); }
/// <summary> /// Update parameters of existing PSD image. Image data is passed in a request stream. /// </summary> public void CreateModifiedPsdFromRequestBody() { Console.WriteLine("Update parameters of a PSD image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { int? channelsCount = 3; var 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 var modifiedPsdRequest = new CreateModifiedPsdRequest(inputImageStream, channelsCount, compressionMethod, fromScratch, outPath, storage); Console.WriteLine( $"Call CreateModifiedPsd with params: channels count:{channelsCount}, compression method:{compressionMethod}"); using (var updatedImage = ImagingApi.CreateModifiedPsd(modifiedPsdRequest)) { SaveUpdatedSampleImageToOutput(updatedImage, true); } } Console.WriteLine(); }
/// <summary> /// Update parameters of existing PSD image, and upload updated image to Cloud Storage. /// </summary> public void ModifyPsdAndUploadToStorage() { Console.WriteLine("Update parameters of a PSD image and upload to cloud storage"); UploadSampleImageToCloud(); int? channelsCount = 3; var compressionMethod = "raw"; bool? fromScratch = null; var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var modifyPsdRequest = new ModifyPsdRequest(SampleImageFileName, channelsCount, compressionMethod, fromScratch, folder, storage); Console.WriteLine( $"Call ModifyPsd with params: channels count:{channelsCount}, compression method:{compressionMethod}"); using (var updatedImage = ImagingApi.ModifyPsd(modifyPsdRequest)) { UploadImageToCloud(GetModifiedSampleImageFileName(), updatedImage); } Console.WriteLine(); }
public void TestGetImageGif() { ImagingApi target = new ImagingApi(APIKEY, APPSID, BASEPATH); StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); string name = "sample.gif"; string backgroundColorIndex = null; string colorResolution = null; bool? hasTrailer = null; bool? interlaced = null; bool? isPaletteSorted = null; string pixelAspectRatio = null; bool? fromScratch = null; string outPath = ""; string folder = ""; string storage = ""; storageApi.PutCreate(name, null, null, System.IO.File.ReadAllBytes("\\temp\\imaging\\resources\\" + name)); ResponseMessage actual; actual = target.GetImageGif(name, backgroundColorIndex, colorResolution, hasTrailer, interlaced, isPaletteSorted, pixelAspectRatio, fromScratch, outPath, folder, storage); Assert.AreEqual(200, actual.Code); Assert.IsInstanceOfType(new ResponseMessage(), actual.GetType()); }
public void TestGetUpdatedImage() { ImagingApi target = new ImagingApi(APIKEY, APPSID, BASEPATH); StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); string name = "TestDemo.tif"; string format = "gif"; int? newWidth = 300; int? newHeight = 300; int? x = 96; int? y = 96; int? rectWidth = 200; int? rectHeight = 200; string rotateFlipMethod = "Rotate180FlipX"; string outPath = ""; string folder = ""; string storage = ""; storageApi.PutCreate(name, null, null, System.IO.File.ReadAllBytes("\\temp\\imaging\\resources\\" + name)); ResponseMessage actual; actual = target.GetUpdatedImage(name, format, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, outPath, folder, storage); Assert.AreEqual(200, actual.Code); Assert.IsInstanceOfType(new ResponseMessage(), actual.GetType()); }
public void TestGetImageFrame() { ImagingApi target = new ImagingApi(APIKEY, APPSID, BASEPATH); StorageApi storageApi = new StorageApi(APIKEY, APPSID, BASEPATH); string name = "sample-multi.tif"; int? frameId = 1; int? newWidth = 200; int? newHeight = 200; int? x = 0; int? y = 0; int? rectWidth = 200; int? rectHeight = 200; string rotateFlipMethod = "Rotate180FlipX"; bool? saveOtherFrames = true; string outPath = ""; string folder = ""; string storage = ""; storageApi.PutCreate(name, null, null, System.IO.File.ReadAllBytes("\\temp\\imaging\\resources\\" + name)); ResponseMessage actual; actual = target.GetImageFrame(name, frameId, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, saveOtherFrames, outPath, folder, storage); Assert.AreEqual(200, actual.Code); Assert.IsInstanceOfType(new ResponseMessage(), actual.GetType()); }
/// <summary> /// Crop an existing image, and upload updated image to Cloud Storage. /// </summary> public void CropImageAndUploadToStorage() { Console.WriteLine("Crops the image and upload to cloud storage"); UploadSampleImageToCloud(); // Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Crop // for possible output formats var format = "jpg"; // Resulting image format. int? x = 10; int? y = 10; int? width = 100; int? height = 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 request = new CropImageRequest(SampleImageFileName, x, y, width, height, format, folder, storage); Console.WriteLine($"Call CropImage with params:x:{x},y:{y}, width:{width}, height:{height}"); using (var updatedImage = ImagingApi.CropImage(request)) { UploadImageToCloud(GetModifiedSampleImageFileName(false, format), updatedImage); } Console.WriteLine(); }
/// <summary> /// Crop an image. Image data is passed in a request stream. /// </summary> public void CreateCroppedImageFromRequestBody() { Console.WriteLine("Crops the image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { // Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Crop // for possible output formats var 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, x, y, width, height, format, outPath, storage); Console.WriteLine($"Call CreateCroppedImage with params:x:{x},y:{y}, width:{width}, height:{height}"); using (var updatedImage = ImagingApi.CreateCroppedImage(request)) { SaveUpdatedSampleImageToOutput(updatedImage, true, format); } } Console.WriteLine(); }
/// <summary> /// Process existing WMF image using given parameters. /// Image data is passed in a request stream. /// </summary> public void CreateModifiedWmfFromRequestBody() { Console.WriteLine("Update parameters of a WMF image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { var 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 var exportFormat = "png"; var postImageWmfRequest = new CreateModifiedWmfRequest(inputImageStream, bkColor, pageWidth, pageHeight, borderX, borderY, fromScratch, outPath, storage, exportFormat); Console.WriteLine( $"Call CreateModifiedWmf with params: background color:{bkColor}, page width:{pageWidth}, page height:{pageHeight}, border X:{borderX}, border Y:{borderY}"); using (var updatedImage = ImagingApi.CreateModifiedWmf(postImageWmfRequest)) { SaveUpdatedSampleImageToOutput(updatedImage, true); } } Console.WriteLine(); }
public void UsingCustomFontsForVectorImageTest() { // custom fonts should be loaded to storage to 'Fonts' folder // 'Fonts' folder should be placed to the root of the cloud storage var imageName = "image.emz"; var format = "png"; string folder = this.TempFolder; string storage = this.TestStorage; this.TestGetRequest( "UsingCustomFontsForVectorImageTest", $"Input image: {imageName}; Output format: {format}", imageName, delegate { var request = new ConvertImageRequest(imageName, format, folder, storage); var response = ImagingApi.ConvertImage(request); Assert.That(Math.Abs(response.Length - 11454), Is.LessThan(100)); return(response); }, null, folder, storage); }
/// <summary> /// Process existing WMF image using given parameters, and upload updated image to Cloud Storage. /// </summary> public void ModifyWmfAndUploadToStorage() { Console.WriteLine("Update parameters of a WMF image and upload to cloud storage"); UploadSampleImageToCloud(); var bkColor = "gray"; int? pageWidth = 300; int? pageHeight = 300; int? borderX = 50; int? borderY = 50; bool?fromScratch = null; var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var exportFormat = "png"; var getImageWmfRequest = new ModifyWmfRequest(SampleImageFileName, bkColor, pageWidth, pageHeight, borderX, borderY, fromScratch, folder, storage, exportFormat); Console.WriteLine( $"Call ModifyWmf with params: background color:{bkColor}, page width:{pageWidth}, page height:{pageHeight}, border X:{borderX}, border Y:{borderY}"); using (var updatedImage = ImagingApi.ModifyWmf(getImageWmfRequest)) { UploadImageToCloud(GetModifiedSampleImageFileName(), updatedImage); } Console.WriteLine(); }
public void CreateObjectBoundsTest(bool saveResultToStorage) { var inputFile = InputTestFiles.FirstOrDefault(f => string.Equals(f.Name, TestImage)); bool removeResult = true; using (var stream = ImagingApi.DownloadFile(new DownloadFileRequest(inputFile.Path, this.TestStorage))) { var request = new CreateObjectBoundsRequest() { imageData = stream, storage = TestStorage, outPath = saveResultToStorage ? TempFolder + "/" + inputFile.Name : null, threshold = 10, includeLabel = true, includeScore = true, allowedLabels = "dog", }; using (var command = new CreateObjectDetectionTestCommand(request, ImagingApi, saveResultToStorage, removeResult)) { ExecuteTestCommand(command, "objectDetection_createobjectbounds_test", $"Input image: {inputFile.Name};", inputFile.Name, TempFolder, TestStorage); } } }
public void ModifyJpegTest() { string name = "test.jpg"; int quality = 65; string compressionType = "progressive"; bool? fromScratch = null; string folder = TempFolder; string storage = this.TestStorage; this.TestGetRequest( "ModifyJpegTest", $"Input image: {name}; Quality: {quality}; Compression type: {compressionType}", name, delegate { var request = new ModifyJpegRequest(name, quality, compressionType, fromScratch, folder, storage); return(ImagingApi.ModifyJpeg(request)); }, delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream) { Assert.NotNull(resultProperties.JpegProperties); Assert.NotNull(originalProperties.JpegProperties); Assert.AreEqual(originalProperties.Width, resultProperties.Width); Assert.AreEqual(originalProperties.Height, resultProperties.Height); }, folder, storage); }
/// <summary> /// Rotate and/or flip an image. /// Image data is passed in a request stream. /// </summary> public void CreateRotateFlippedImageFromRequestBody() { Console.WriteLine("Rotate/flip an image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { // Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-RotateFlip // for possible output formats var format = "gif"; var 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 var createRotateFlippedImageRequest = new CreateRotateFlippedImageRequest(inputImageStream, method, format, outPath, storage); Console.WriteLine($"Call CreateRotateFlippedImage with params: method:{method}, format:{format}"); using (var updatedImage = ImagingApi.CreateRotateFlippedImage(createRotateFlippedImageRequest)) { SaveUpdatedSampleImageToOutput(updatedImage, true, format); } Console.WriteLine(); } }
/// <summary> /// Perform scaling, cropping and flipping of an image in a single request. Image data is passed in a request stream. /// </summary> public void CreateUpdatedImageFromRequestBody() { Console.WriteLine("Update parameters of an image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { // Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-Update // for possible output formats var format = "pdf"; int? newWidth = 300; int? newHeight = 450; int? x = 10; int? y = 10; int? rectWidth = 200; int? rectHeight = 300; var 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 var postImageUpdateRequest = new CreateUpdatedImageRequest(inputImageStream, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, format, outPath, storage); Console.WriteLine( $"Call CreateUpdatedImage with params: new width:{newWidth}, new height:{newHeight}, x:{x}, y:{y}, rect width:{rectWidth}, rectHeight:{rectHeight}, rotate/flip method:{rotateFlipMethod}, format:{format}"); using (var updatedImage = ImagingApi.CreateUpdatedImage(postImageUpdateRequest)) { SaveUpdatedSampleImageToOutput(updatedImage, true); } } Console.WriteLine(); }
/// <summary> /// Rotate and/or flip an image, and upload updated image to Cloud Storage /// </summary> public void RotateFlipImageAndUploadToStorage() { Console.WriteLine("Rotate/flip an image and upload to cloud storage"); UploadSampleImageToCloud(); // Please refer to https://docs.aspose.cloud/display/imagingcloud/Supported+File+Formats#SupportedFileFormats-RotateFlip // for possible output formats var format = "gif"; var method = "Rotate90FlipX"; // RotateFlip method var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var getImageRotateFlipRequest = new RotateFlipImageRequest( SampleImageFileName, method, format, folder, storage); Console.WriteLine($"Call RotateFlipImage with params: method:{method}, format:{format}"); using (var updatedImage = ImagingApi.RotateFlipImage(getImageRotateFlipRequest)) { UploadImageToCloud(GetModifiedSampleImageFileName(false, format), updatedImage); } Console.WriteLine(); }
/// <summary> /// Update parameters of existing JPEG2000 image. Image data is passed in a request stream. /// </summary> public void CreateModifiedJpeg2000FromRequestBody() { Console.WriteLine("Update parameters of a Jpeg2000 image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { var codec = "jp2"; var 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 var postImageJpeg2000Request = new CreateModifiedJpeg2000Request(inputImageStream, comment, codec, fromScratch, outPath, storage); Console.WriteLine($"Call CreateModifiedJpeg2000 with params: codec:{codec}, comment:{comment}"); using (var updatedImage = ImagingApi.CreateModifiedJpeg2000(postImageJpeg2000Request)) { SaveUpdatedSampleImageToOutput(updatedImage, true); } } Console.WriteLine(); }
public void ModifyWebPTest() { string name = "Animation.webp"; bool lossless = true; int quality = 90; int animLoopCount = 5; string animBackgroundColor = "gray"; bool? fromScratch = null; string folder = TempFolder; string storage = this.TestStorage; this.TestGetRequest( "ModifyWebPTest", $"Input image: {name}; AnimBackgroundColor: {animBackgroundColor}; Lossless: {lossless}; Quality: {quality}; AnimLoopCount: {animLoopCount}", name, delegate { var request = new ModifyWebPRequest(name, lossless, quality, animLoopCount, animBackgroundColor, fromScratch, folder, storage); return(ImagingApi.ModifyWebP(request)); }, delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream) { Assert.NotNull(resultProperties.WebPProperties); Assert.NotNull(originalProperties.WebPProperties); Assert.AreEqual(originalProperties.Width, resultProperties.Width); Assert.AreEqual(originalProperties.Height, resultProperties.Height); }, folder, storage); }
/// <summary> /// Update parameters of GIF image. Image data is passed in a request stream. /// </summary> public void CreateModifiedGifFromRequestBody() { Console.WriteLine("Update parameters of a GIF image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { 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 var postImageGifRequest = new CreateModifiedGifRequest(inputImageStream, backgroundColorIndex, colorResolution, hasTrailer, interlaced, isPaletteSorted, pixelAspectRatio, fromScratch, outPath, storage); Console.WriteLine( $"Call CreateModifiedGif with params: background color index:{backgroundColorIndex}, color resolution:{colorResolution}, has trailer:{hasTrailer}, interlaced:{interlaced}, is palette sorted:{isPaletteSorted}, pixel aspect ratio:{pixelAspectRatio}"); using (var updatedImage = ImagingApi.CreateModifiedGif(postImageGifRequest)) { SaveUpdatedSampleImageToOutput(updatedImage, true); } } Console.WriteLine(); }
public void CreateModifiedWebPTest(bool saveResultToStorage) { string name = "Animation.webp"; bool lossless = true; int quality = 90; int animLoopCount = 5; string animBackgroundColor = "gray"; bool? fromScratch = null; string outName = $"{name}_specific.webp"; string folder = TempFolder; string storage = this.TestStorage; this.TestPostRequest( "CreateModifiedWebPTest", saveResultToStorage, $"Input image: {name}; AnimBackgroundColor: {animBackgroundColor}; Lossless: {lossless}; Quality: {quality}; AnimLoopCount: {animLoopCount}", name, outName, delegate(Stream inputStream, string outPath) { var request = new CreateModifiedWebPRequest(inputStream, lossless, quality, animLoopCount, animBackgroundColor, fromScratch, outPath, storage); return(ImagingApi.CreateModifiedWebP(request)); }, delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream) { Assert.NotNull(resultProperties.WebPProperties); Assert.NotNull(originalProperties.WebPProperties); Assert.AreEqual(originalProperties.Width, resultProperties.Width); Assert.AreEqual(originalProperties.Height, resultProperties.Height); }, folder, storage); }
public void ModifyEmfTest() { string name = "test.emf"; string bkColor = "gray"; int pageWidth = 300; int pageHeight = 300; int borderX = 50; int borderY = 50; bool? fromScratch = null; string folder = TempFolder; string storage = this.TestStorage; this.TestGetRequest( "ModifyEmfTest", $"Input image: {name}; BackColor: {bkColor}; Page width: {pageWidth}; Page height: {pageHeight}; BorderX: {borderX}; BorderY: {borderY}", name, delegate { var request = new ModifyEmfRequest(name, bkColor, pageWidth, pageHeight, borderX, borderY, fromScratch, folder, storage); return(ImagingApi.ModifyEmf(request)); }, delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream) { int width = pageWidth + borderX * 2; int height = pageHeight + borderY * 2; Assert.IsNotNull(resultProperties.PngProperties); Assert.AreEqual(width, resultProperties.Width); Assert.AreEqual(height, resultProperties.Height); }, folder, storage); }
/// <summary> /// Update parameters of existing JPEG image. Image data is passed in a request stream. /// </summary> public void CreateModifiedJpegFromRequestBody() { Console.WriteLine("Update parameters of a JPEG image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { int? quality = 65; var 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 var modifiedJpgRequest = new CreateModifiedJpegRequest(inputImageStream, quality, compressionType, fromScratch, outPath, storage); Console.WriteLine( $"Call CreateModifiedJpeg with params: quality:{quality}, compression type:{compressionType}"); using (var updatedImage = ImagingApi.CreateModifiedJpeg(modifiedJpgRequest)) { SaveUpdatedSampleImageToOutput(updatedImage, true); } } Console.WriteLine(); }
// Update parameters of a BMP image, and upload updated image to Cloud Storage. public void ModifyBmpAndUploadToStorage() { Console.WriteLine("Update parameters of a BMP image and upload to cloud storage"); // Upload local image to Cloud Storage UploadSampleImageToCloud(); int? bitsPerPixel = 32; int? horizontalResolution = 300; int? verticalResolution = 300; bool? fromScratch = null; var folder = CloudPath; // Input file is saved at the Examples folder in the storage string storage = null; // We are using default Cloud Storage var request = new ModifyBmpRequest( SampleImageFileName, bitsPerPixel, horizontalResolution, verticalResolution, fromScratch, folder, storage); Console.WriteLine( $"Call ModifyBmp with params: bits per pixel:{bitsPerPixel}, horizontal resolution:{horizontalResolution}, vertical resolution:{verticalResolution}"); using (var updatedImage = ImagingApi.ModifyBmp(request)) { // Upload updated image to Cloud Storage UploadImageToCloud(GetModifiedSampleImageFileName(), updatedImage); } Console.WriteLine(); }
/// <summary> /// Update parameters of existing Webp image. asposelogo.webpImage data is passed in a request stream. /// </summary> public void CreateModifiedWebPFromRequestBody() { Console.WriteLine("Update parameters of a WEBP image from request body"); using (var inputImageStream = File.OpenRead(Path.Combine(ExampleImagesFolder, SampleImageFileName))) { bool? lossless = true; int? quality = 90; int? animLoopCount = 5; var 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 var modifiedImageWebPRequest = new CreateModifiedWebPRequest(inputImageStream, lossless, quality, animLoopCount, animBackgroundColor, fromScratch, outPath, storage); Console.WriteLine( $"Call CreateModifiedWebP with params: lossless:{lossless}, quality:{quality}, anim loop count:{animLoopCount}, anim background color:{animBackgroundColor}"); using (var updatedImage = ImagingApi.CreateModifiedWebP(modifiedImageWebPRequest)) { SaveUpdatedSampleImageToOutput(updatedImage, true); } } Console.WriteLine(); }