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);
        }
Ejemplo n.º 2
0
        /// <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();
        }