Documentation > CMS Template API Library > PanelEntry > CreateThumbnail(Img,String,Int32,Int32,Int32)
CreateThumbnail
Creates a thumbnail of the specified size from the currently loaded image. A ThumbnailKey is required. The resulting image will be stored on the panel. Note: Due to memory limitations, the pixel count of the source image cannot be more than 10 million. Note: Do not include the post fix ":..." part of the name. Use the shortname "my_field", not "my_field:1"
public CrownPeak.CMSAPI.ImgResult CreateThumbnail(Img,String,Int32,Int32,Int32)
Parameters
Name | Description | Type |
---|---|---|
img | The image to be used to create the thumbnail | CrownPeak.CMSAPI.Img |
thumbnailKey | The Key used to refer to the thumbnail later as part of the asset's content. | System.String |
width | The width. | System.Int32 |
height | The height. | System.Int32 |
qualityByPercent | Optional: The Quality of the saved JPG as a percent. Higher numbers have higher quality, but also bigger sizes. | System.Int32 |
Code Example
C#
Sample:
// Usually called from post_input.aspx List<PanelEntry> panels = context.InputForm.GetPanels("imageList"); foreach(PanelEntry panel in panels) { if (panel.UploadedFiles["my_photo"] != null) { Img img = Img.Load(panel.UploadedFiles["my_photo"]); if (!img.HasError) { ImgResult result = panel.CreateThumbnail(img, "my_photo_thumbnail_panelpost_50_", 50,50); if (result.HasError) { panel["Error"] = result.ErrorMessage; } } } }