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

CropImage

Crop the current image 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(Img,String,LassoParams,Int32)


Returns

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

Parameters

NameDescriptionType
img The image from which the result will be cropped CrownPeak.CMSAPI.Img
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;
Asset imageAsset = Asset.Load(" /Assets/images 2/gundam.jpg");
Img imageToCrop = Img.Load(imageAsset);      
ImgResult result = context.PanelEntry.CropImage(imageToCrop, "cropped_image", lParams, 100);

Connect with Crownpeak