Example #1
0
        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>
        ///     Update parameters of existing JPEG image, and upload updated image to Cloud Storage.
        /// </summary>
        public void ModifyJpegAndUploadToStorage()
        {
            Console.WriteLine("Update parameters of a JPEG image and upload to cloud storage");

            UploadSampleImageToCloud();

            int?   quality         = 65;
            var    compressionType = "progressive";
            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 modifyJpegRequest =
                new ModifyJpegRequest(SampleImageFileName, quality, compressionType, fromScratch, folder, storage);

            Console.WriteLine($"Call ModifyJpeg with params: quality:{quality}, compression type:{compressionType}");

            using (var updatedImage = ImagingApi.ModifyJpeg(modifyJpegRequest))
            {
                UploadImageToCloud(GetModifiedSampleImageFileName(), updatedImage);
            }

            Console.WriteLine();
        }