/// <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 CreateModifiedGifTest(bool saveResultToStorage) { string name = "test.gif"; int? backgroundColorIndex = 5; int? colorResolution = 4; bool hasTrailer = true; bool interlaced = false; bool isPaletteSorted = true; int pixelAspectRatio = 4; bool? fromScratch = null; string outName = $"{name}_specific.gif"; string folder = TempFolder; string storage = this.TestStorage; this.TestPostRequest( "CreateModifiedGifTest", saveResultToStorage, $"Input image: {name}; Back color index: {backgroundColorIndex}; Color resolution: {colorResolution}; Has trailer: {hasTrailer}; " + $"Interlaced: {interlaced}; Is palette sorted: {isPaletteSorted}; Pixel aspect ratio: {pixelAspectRatio}", name, outName, delegate(Stream inputStream, string outPath) { var request = new CreateModifiedGifRequest(inputStream, backgroundColorIndex, colorResolution, hasTrailer, interlaced, isPaletteSorted, pixelAspectRatio, fromScratch, outPath, storage); return(ImagingApi.CreateModifiedGif(request)); }, delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream) { Assert.IsNotNull(resultProperties.GifProperties); // TODO: enable when IMAGINGCLOUD-51 is done //Assert.AreEqual(hasTrailer, resultProperties.GifProperties.HasTrailer); Assert.AreEqual(pixelAspectRatio, resultProperties.GifProperties.PixelAspectRatio); Assert.IsNotNull(originalProperties.GifProperties); Assert.AreEqual(originalProperties.Width, resultProperties.Width); Assert.AreEqual(originalProperties.Height, resultProperties.Height); }, folder, storage); }