Documentation > CMS Template API Library > PanelEntry > CropImage(UploadedFile,String,LassoParams,Int32)


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 panel using thumbnailKey as a fieldname.

public CrownPeak.CMSAPI.ImgResult CropImage(UploadedFile,String,LassoParams,Int32)


ImgResult. Contains the new Img. Use HasError to check for errors.


uploadedFile UploadedFile that contains an Image CrownPeak.CMSAPI.UploadedFile
thumbnailKey A key used to save the result System.String
lParams Optional: if panel is part of an InputForm in post input. 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


// post_input.aspx:
// Take the file uploaded with the name "original_image" crop it and store it with the name "cropped_Image"
LassoParams lParams = new LassoParams();
lParams.BoxHeight = 200;
lParams.BoxLeft = 150;
lParams.BoxTop = 150;
lParams.BoxWidth = 50;
lParams.ScaleHeight = 50;
lParams.ScaleWidth = 75;

ImgResult img = context.PanelEntry.CropImage(context.InputForm.UploadedFiles["original_image"], "cropped_image", lParams, 100);
if (img.HasError)
  context.Error "Crop error " + img.ErrorMessage;

Connect with Crownpeak