/// <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();
        }
        public void CreateCroppedImageTest(string formatExtension, bool saveResultToStorage, params string[] additionalExportFormats)
        {
            string name    = null;
            int?   x       = 10;
            int?   y       = 10;
            int?   width   = 100;
            int?   height  = 150;
            string folder  = TempFolder;
            string storage = this.TestStorage;
            string outName = null;

            List <string> formatsToExport = new List <string>(this.BasicExportFormats);

            foreach (string additionalExportFormat in additionalExportFormats)
            {
                if (!formatsToExport.Contains(additionalExportFormat))
                {
                    formatsToExport.Add(additionalExportFormat);
                }
            }

            foreach (StorageFile inputFile in BasicInputTestFiles)
            {
                if (inputFile.Name.EndsWith(formatExtension))
                {
                    name = inputFile.Name;
                }
                else
                {
                    continue;
                }

                foreach (string format in formatsToExport)
                {
                    outName = $"{name}_crop.{format ?? formatExtension.Substring(1)}";

                    this.TestPostRequest(
                        "CropImageTest",
                        saveResultToStorage,
                        $"Input image: {name}; Output format: {format ?? "null"}; Width: {width}; Height: {height}; X: {x}; Y: {y}",
                        name,
                        outName,
                        delegate(Stream inputStream, string outPath)
                    {
                        var request = new CreateCroppedImageRequest(inputStream, x, y, width, height, format, outPath, storage);
                        return(ImagingApi.CreateCroppedImage(request));
                    },
                        delegate(ImagingResponse originalProperties, ImagingResponse resultProperties, Stream resultStream)
                    {
                        Assert.AreEqual(width, resultProperties.Width);
                        Assert.AreEqual(height, resultProperties.Height);
                    },
                        folder,
                        storage);
                }
            }
        }