/// <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();
        }
Exemple #2
0
        public void CreateModifiedJpeg2000Test(bool saveResultToStorage)
        {
            string name        = "test.j2k";
            string codec       = "jp2";
            string comment     = "Aspose";
            bool?  fromScratch = null;
            string outName     = $"{name}_specific.jp2";
            string folder      = TempFolder;
            string storage     = this.TestStorage;

            this.TestPostRequest(
                "CreateModifiedJpeg2000Test",
                saveResultToStorage,
                $"Input image: {name}; Comment: {comment}; Codec: {codec}",
                name,
                outName,
                delegate(Stream inputStream, string outPath)
            {
                var request = new CreateModifiedJpeg2000Request(inputStream, comment, codec, fromScratch, outPath, storage);
                return(ImagingApi.CreateModifiedJpeg2000(request));
            },
                delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream)
            {
                Assert.IsNotNull(resultProperties.Jpeg2000Properties);

                Assert.IsNotNull(resultProperties.Jpeg2000Properties.Codec);
                Assert.AreEqual(codec, resultProperties.Jpeg2000Properties.Codec.ToString().ToLower());
                Assert.IsNotNull(resultProperties.Jpeg2000Properties.Comments);
                Assert.AreEqual(comment, resultProperties.Jpeg2000Properties.Comments[0]);

                Assert.IsNotNull(originalProperties.Jpeg2000Properties);
                Assert.AreEqual(originalProperties.Width, resultProperties.Width);
                Assert.AreEqual(originalProperties.Height, resultProperties.Height);
                Assert.IsNotNull(originalProperties.Jpeg2000Properties.Comments);
                Assert.AreNotEqual(comment, originalProperties.Jpeg2000Properties.Comments[0]);
            },
                folder,
                storage);
        }