/// <summary> /// Perform scaling, cropping and flipping of an image in single request. Image is passed as request body. /// </summary> /// <param name="format">Save image in another format. By default format remains the same</param> /// <param name="newWidth">New Width of the scaled image.</param> /// <param name="newHeight">New height of the scaled image.</param> /// <param name="x">X position of start point for cropping rectangle</param> /// <param name="y">Y position of start point for cropping rectangle</param> /// <param name="rectWidth">Width of cropping rectangle</param> /// <param name="rectHeight">Height of cropping rectangle</param> /// <param name="outPath">Path to updated file. It can be a Local Path or a path on cloud storage e.g c:\out.jpg or MyFolder/out.jpg</param> /// <param name="inputFilePath">Input Jpg file that will be passed as request body</param> /// <param name="rotateFlipMethod">RotateFlip method. Default is RotateNoneFlipNone.</param> public void PerformScalingCroppingAndFlippingOfAnImage(ImageFormat format, int newWidth, int newHeight, int x, int y, int rectWidth, int rectHeight, string outPath, string inputFilePath, RotateFlipMethod rotateFlipMethod = RotateFlipMethod.RotateNoneFlipNone) { // POST imaging/updateImage?appSid={appSid}&format={format}&newWidth={newWidth}&newHeight={newHeight}&x={x}&y={y}&rectWidth={rectWidth}&rectHeight={rectHeight}&rotateFlipMethod={rotateFlipMethod}&outPath={outPath} string apiUrl = string.Format(@"imaging/updateImage?format={0}&newWidth={1}&newHeight={2}&x={3}&y={4}&rectWidth={5}&rectHeight={6}&rotateFlipMethod={7}&outPath={8}", format, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, (outPath.Contains(@":\") ? string.Empty : outPath)); if (!string.IsNullOrEmpty(outPath) && Directory.Exists(Path.GetDirectoryName(outPath))) { using (Stream responseStream = ServiceController.GetStreamWithPost(apiUrl, AppSid, AppKey, File.ReadAllBytes(inputFilePath))) using (Stream file = File.OpenWrite(outPath)) { ServiceController.CopyStream(responseStream, file); } } else { ServiceController.GetStreamWithPost(apiUrl, AppSid, AppKey, File.ReadAllBytes(inputFilePath)); } }
/// <summary> /// Perform scaling, cropping and flipping of an image in single request. /// </summary> /// <param name="name">The image name.</param> /// <param name="format">Save image in another format. By default format remains the same</param> /// <param name="newWidth">New Width of the scaled image.</param> /// <param name="newHeight">New height of the scaled image.</param> /// <param name="x">X position of start point for cropping rectangle</param> /// <param name="y">Y position of start point for cropping rectangle</param> /// <param name="rectWidth">Width of cropping rectangle</param> /// <param name="rectHeight">Height of cropping rectangle</param> /// <param name="outPath">Path to updated file. It can be a Local Path or a path on cloud storage e.g c:\out.jpg or MyFolder/out.jpg</param> /// <param name="folder">Folder with image to process.</param> /// <param name="rotateFlipMethod">RotateFlip method. Default is RotateNoneFlipNone.</param> /// <param name="storage">Image storage</param> public void PerformScalingCroppingAndFlippingOfAnImage(string name, ImageFormat format, int newWidth, int newHeight, int x, int y, int rectWidth, int rectHeight, string outPath, string folder, RotateFlipMethod rotateFlipMethod = RotateFlipMethod.RotateNoneFlipNone, string storage = "") { // GET imaging/{name}/updateImage?appSid={appSid}&format={format}&newWidth={newWidth}&newHeight={newHeight}&x={x}&y={y}&rectWidth={rectWidth}&rectHeight={rectHeight}&rotateFlipMethod={rotateFlipMethod}&outPath={outPath}&folder={folder}&storage={storage} string apiUrl = string.Format(@"imaging/{0}/updateImage?format={1}&newWidth={2}&newHeight={3}&x={4}&y={5}&rectWidth={6}&rectHeight={7}&rotateFlipMethod={8}&outPath={9}&folder={10}&storage={11}", name, format, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, (outPath.Contains(@":\") ? string.Empty : outPath), folder, storage); if (!string.IsNullOrEmpty(outPath) && Directory.Exists(Path.GetDirectoryName(outPath))) { using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey)) using (Stream file = File.OpenWrite(outPath)) { ServiceController.CopyStream(responseStream, file); } } else { ServiceController.Get(apiUrl, AppSid, AppKey); } }
/// <summary> /// Rotate and flip existing image /// </summary> /// <param name="name">The image name.</param> /// <param name="format">Output file format.</param> /// <param name="method">RotateFlip method.</param> /// <param name="outPath">Path to updated file. It can be a Local Path or a path on cloud storage e.g c:\out.jpg or MyFolder/out.jpg</param> /// <param name="folder">Folder with image to process.</param> /// <param name="storage">Image storage</param> public void RotateFlipExistingImage(string name, ImageFormat format, RotateFlipMethod method, string outPath, string folder, string storage = "") { // GET imaging/{name}/rotateflip?format={format}&appSid={appSid}&method={method}&outPath={outPath}&folder={folder}&storage={storage} string apiUrl = string.Format(@"imaging/{0}/rotateflip?format={1}&method={2}&outPath={3}&folder={4}&storage={5}", name, format, method, (outPath.Contains(@":\") ? string.Empty : outPath), folder, storage); if (!string.IsNullOrEmpty(outPath) && Directory.Exists(Path.GetDirectoryName(outPath))) { using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey)) using (Stream file = File.OpenWrite(outPath)) { ServiceController.CopyStream(responseStream, file); } } else { ServiceController.Get(apiUrl, AppSid, AppKey); } }
/// <summary> /// Rotate and flip an image /// </summary> /// <param name="format">Output file format.</param> /// <param name="method">RotateFlip method.</param> /// <param name="outPath">Path to updated file. It can be a Local Path or a path on cloud storage e.g c:\out.jpg or MyFolder/out.jpg</param> /// <param name="inputFilePath">Input Jpg file that will be passed as request body</param> public void RotateFlipImage(ImageFormat format, RotateFlipMethod method, string outPath, string inputFilePath) { // POST imaging/rotateflip?format={format}&appSid={appSid}&method={method}&outPath={outPath} string apiUrl = string.Format(@"imaging/rotateflip?format={0}&method={1}&outPath={2}", format, method, (outPath.Contains(@":\") ? string.Empty : outPath)); if (!string.IsNullOrEmpty(outPath) && Directory.Exists(Path.GetDirectoryName(outPath))) { using (Stream responseStream = ServiceController.GetStreamWithPost(apiUrl, AppSid, AppKey, File.ReadAllBytes(inputFilePath))) using (Stream file = File.OpenWrite(outPath)) { ServiceController.CopyStream(responseStream, file); } } else { ServiceController.GetStreamWithPost(apiUrl, AppSid, AppKey, File.ReadAllBytes(inputFilePath)); } }
/// <summary> /// Update properties of frame in existing TIFF image. /// </summary> /// <param name="name">The image name.</param> /// <param name="frameId">Number of frame.</param> /// <param name="newWidth">New width of the scaled image.</param> /// <param name="newHeight">New height of the scaled image.</param> /// <param name="x">X position of start point for cropping rectangle</param> /// <param name="y">Y position of start point for cropping rectangle</param> /// <param name="rectWidth">Width of cropping rectangle</param> /// <param name="rectHeight">Height of cropping rectangle</param> /// <param name="saveOtherFrames">Include all other frames or just specified frame in response.</param> /// <param name="outPath">Path to updated file. It can be a Local Path or a path on cloud storage e.g c:\out.tiff or MyFolder/out.tiff</param> /// <param name="folder">Folder with image to process.</param> /// <param name="rotateFlipMethod">RotateFlip method</param> /// <param name="storage">Image storage</param> public void UpdatePropertiesOfFrameInExistingTiffImage(string name, int frameId, int newWidth, int newHeight, int x, int y, int rectWidth, int rectHeight, bool saveOtherFrames, string outPath, string folder, RotateFlipMethod rotateFlipMethod = RotateFlipMethod.RotateNoneFlipNone, string storage = "") { // GET imaging/{name}/frames/{frameId}?appSid={appSid}&newWidth={newWidth}&newHeight={newHeight}&x={x}&y={y}&rectWidth={rectWidth}&rectHeight={rectHeight}&rotateFlipMethod={rotateFlipMethod}&saveOtherFrames={saveOtherFrames}&outPath={outPath}&folder={folder}&storage={storage} string apiUrl = string.Format(@"imaging/{0}/frames/{1}?newWidth={2}&newHeight={3}&x={4}&y={5}&rectWidth={6}&rectHeight={7}&rotateFlipMethod={8}&outPath={9}&folder={10}&storage={11}", name, frameId, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, (outPath.Contains(@":\") ? string.Empty : outPath), folder, storage); if (saveOtherFrames) { apiUrl = apiUrl + string.Format("&saveOtherFrames={0}", saveOtherFrames); } if (!string.IsNullOrEmpty(outPath) && Directory.Exists(Path.GetDirectoryName(outPath))) { using (Stream responseStream = ServiceController.GetStream(apiUrl, AppSid, AppKey)) using (Stream file = File.OpenWrite(outPath)) { ServiceController.CopyStream(responseStream, file); } } else { ServiceController.Get(apiUrl, AppSid, AppKey); } }