Documentation > CMS Template API Library > Asset > CropImage(UploadedFile,String,LassoParams,Int32)
CropImage
Crop the current image stored in the UploadedFile using the box defined by x, y, xx, yy and scaling to width and height. Saving on the asset using thumbnailKey as a fieldname.
public CrownPeak.CMSAPI.ImgResult CropImage(UploadedFile,String,LassoParams,Int32)
Returns
ImgResult. Contains the new Img. Use HasError to check for errors.
Parameters
Name | Description | Type |
---|---|---|
uploadedFile | UploadedFile that contains an Image | CrownPeak.CMSAPI.UploadedFile |
thumbnailKey | A key used to save the result | System.String |
lParams | LassoParams that specify how to crop and scale the image | CrownPeak.CMSAPI.LassoParams |
qualityByPercent | Optional: The quality of the resulting image as a percent. Defaults to 75. | System.Int32 |
Code Example
C#
Sample:
LassoParams lParams = new LassoParams(); lParams.BoxHeight = 200; lParams.BoxLeft = 150; lParams.BoxTop = 150; lParams.BoxWidth = 50; lParams.ScaleHeight = 50; lParams.ScaleWidth = 75; UploadedFile imageToCrop = asset.UploadedFiles["image_to_crop"]; ImgResult result = asset.CropImage(imageToCrop, "cropped_image", lParams, 100);