Documentation > CMS Template API Library > InputForm > CropImage(Img,String,LassoParams,Int32)
CropImage
Crop the given image as specified. Lasso Params not saved with this call.
public CrownPeak.CMSAPI.ImgResult CropImage(Img,String,LassoParams,Int32)
Parameters
| Name | Description | Type |
|---|---|---|
| img | The image to crop | CrownPeak.CMSAPI.Img |
| thumbnailKey | The name of the key to save the thumbnail into. | System.String |
| lParams | LassoParams that specify how to crop and scale the image | CrownPeak.CMSAPI.LassoParams |
| qualityByPercent | Optional: The image quality of the created image. Defaults to 75. | System.Int32 |
Code Example
C#
Sample:
// input.aspx : Important: First have an upload with lasso params in the input form
ShowAcquireParams aParams = new ShowAcquireParams();
aParams.DefaultFolder = "/Assets/images";
aParams.ShowLasso = true;
// final cropped image will be scaled down to 100 pixels
aParams.LassoHeight = 100;
aParams.LassoWidth = 100;
// initial dimensions for the selection "lasso", after a successful crop the current dimensions will be saved and used on the input form the next time.
aParams.LassoBoxTop = 0;
aParams.LassoBoxLeft = 0;
aParams.LassoBoxWidth = 200;
aParams.LassoBoxHeight = 200;
//The original will be scaled down to not more than 600 on each side
aParams.AddAdditionalImage("original_image", 600,600);
Input.ShowAcquireImage("Original", "original_image", aParams);
// post_input.aspx:
// Take the file uploaded with the name "original_image" crop it as defined on the input form and store it with the name "cropped_Image"
ImgResult img = context.InputForm.CropImage(context.InputForm.UploadedFiles["original_image"].Img, "cropped_image");
if (img.HasError)
{
context.Error "Crop error " + img.ErrorMessage;
}