/// <summary> /// Constrains the current image, resizing it to fit within the given dimensions whilst keeping its aspect ratio. /// </summary> /// <param name="size"> /// The <see cref="T:System.Drawing.Size"/> containing the maximum width and height to set the image to. /// </param> /// <returns> /// The current instance of the <see cref="T:ImageProcessor.ImageFactory"/> class. /// </returns> public ImageFactory Constrain(Size size) { if (this.ShouldProcess) { int width = size.Width; int height = size.Height; var constrainSettings = new Dictionary <string, string> { { "MaxWidth", width.ToString("G") }, { "MaxHeight", height.ToString("G") } }; Constrain constrain = new Constrain { DynamicParameter = new Size(width, height), Settings = constrainSettings }; this.Image = constrain.ProcessImage(this); } return(this); }
public string Post([FromBody] Constrain req) { var response = Constrain.ProcessImage(req); return(response); }