Create Thumbnail
Audience:
Low-code EngineersSkill Prerequisites:
Actions,Tokens,Forms
Makes a resized copy of an image, for example a small preview of a photo a user uploaded, and saves it in a portal folder. You choose the size, whether the image is cropped to fit exactly, and the image quality. The original image isn't changed.
This action requires the Drawing feature package to be licensed. If it isn't, the action fails with a not-licensed error.
Typical Use Cases
- Create a small preview of a profile photo or product image when a form is submitted
- Create a square thumbnail for a gallery by cropping the center of the image
- Reduce the size of large uploaded photos before showing them on a page
- Create a thumbnail for each file in a multiple file upload
Don't use it to
- Change the file format, for example from PNG to JPEG. The thumbnail keeps the original file's format and extension.
- Edit the original image. The action always saves a new file.
- Process PDFs or documents. It only works with images.
Related Actions
| Action Name | Description |
|---|---|
| Get or Create Folder | Creates the folder for the thumbnails ahead of time and returns its details. |
| Copy File | Copies a file without changing it. |
| Delete File | Deletes a thumbnail you no longer need. |
Input Parameter Reference
| Parameter | Description | Supports Tokens | Default | Required |
|---|---|---|---|---|
| Image | The image to resize. In button actions, pick a Single File Upload field. In the actions of a multiple file upload, switch to an expression and use a token such as [AbsoluteUrl]. If it's empty, or the file isn't found, the action does nothing. | Yes | empty | Yes |
| Output Folder | The portal folder to save the thumbnail in. It's created if it doesn't exist. | Yes | empty | Yes |
| Name | The thumbnail's file name, without the extension, for example [UserID]-small. The original file's extension is added. | Yes | empty string | Yes |
| Width | The thumbnail's width in pixels. | Yes | empty string | See below |
| Height | The thumbnail's height in pixels. | Yes | empty string | See below |
| Crop | When checked, the thumbnail is exactly Width × Height, and the parts of the image that don't fit are cut off. When unchecked, the whole image is kept and fitted inside that size. | No | Unchecked | No |
| Stretch | When checked, small images are enlarged to reach the size. When unchecked, images are never made bigger than they are. | No | Unchecked | No |
| Horizontal | Which part of the image to keep when cropping sideways: Left, Center or Right. | Yes | Center | No |
| Vertical | Which part of the image to keep when cropping up and down: Top, Center or Bottom. | Yes | Center | No |
| Compression | The image quality, from 1 (smallest file, lowest quality) to 100 (best quality). It mainly affects JPEG images. Empty or 0 saves with the default quality. | Yes | empty string | No |
| Token Name | The name of the output token. See Output Parameters Reference. | Yes | thumbnail | No |
At least one of Width and Height is required. If you give only one, the other is calculated so that the image keeps its proportions.
Output Parameters Reference
The action creates these tokens, using Token Name. If Token Name is empty, they start with thumbnail, for example [thumbnail:AbsoluteUrl].
| Token | Contains |
|---|---|
[<TokenName>:FileId] | The ID of the thumbnail file. |
[<TokenName>:FileName] | The file name without the extension. |
[<TokenName>:FileExtension] | The extension, without the dot, for example jpg. |
[<TokenName>:FileNameAndExtension] | The file name with the extension. |
[<TokenName>:FilePath] | The physical path on the server. |
[<TokenName>:RelativeUrl] | A LinkClick URL for the file, relative to the site. |
[<TokenName>:AbsoluteUrl] | A full LinkClick URL for the file. |
[<TokenName>:NormalRelativeUrl] | The direct URL of the file, relative to the site. Use this in an <img> tag. |
[<TokenName>:NormalAbsoluteUrl] | The full direct URL of the file. |
[<TokenName>:Base64] | The file's content, Base64 encoded. |
[<TokenName>:MimeType] | The file's content type, for example image/jpeg. |
[<TokenName>:FileSize] | The file size in a readable form. :FileSizeB, :FileSizeKB, :FileSizeMB and :FileSizeGB give the size in a specific unit. |
When the image comes from a Single File Upload field, the action also sets [<FieldName>:FileOrThumbnailNameAndExtension] to the thumbnail's file name.
In the actions of a multiple file upload, it adds each thumbnail to comma-separated lists in [<FieldName>:ThumbanilUrls], [<FieldName>:ThumbanilNames] and [<FieldName>:ThumbanilIds]. The misspelling "Thumbanil" is how the product names these tokens.
How the size is calculated
The result depends on Crop and Stretch. For example, for a 1200 × 800 photo with Width 300 and Height 300:
| Crop | Stretch | Result |
|---|---|---|
| Unchecked | Unchecked | 300 × 200. The whole image, fitted inside 300 × 300. |
| Checked | Unchecked | 300 × 300. The image is resized to 450 × 300, then the middle (with Horizontal Center) is cut out. |
| Unchecked | Checked | 300 × 200. Same as the first row, but a smaller image would be enlarged to fit. |
| Checked | Checked | 300 × 300. Same as the second row, but a smaller image would be enlarged to fill it. |
With Stretch unchecked, an image that's already smaller than the requested size keeps its original size.
Considerations
- The format doesn't change. The thumbnail has the same extension as the original. JPEG, BMP and TIFF images are saved in their own format. Other formats, such as GIF, are saved as PNG data but keep their original extension, which some programs may not open correctly.
- Always fill in Name. If it's empty, the file is called just
.jpg(or the original extension), and every thumbnail overwrites the last one. - Existing files are replaced. If a file with the same name is already in the folder, it's overwritten. Include something unique in Name, such as an ID, to keep one thumbnail per image.
- A missing image isn't an error. If Image is empty or the file can't be found, the action does nothing and no tokens are created. Check
[<TokenName>:FileId] != ""before using the tokens. - Numbers only. Width, Height and Compression must be whole numbers. Anything else makes the action fail.
- URLs need a web request. The URL tokens are built from the current page request. Workflows and scheduled jobs run as Automation jobs without one, so the action fails there after the thumbnail is saved.
Examples
To understand how to use the below examples, please see Running Examples.
1. Square profile picture
This action crops the uploaded Photo into a 200 × 200 square, taken from the center, and saves it in the Profiles folder as <UserID>-avatar. The URL is then in [Avatar:NormalRelativeUrl].
{
"Title": "Create Thumbnail",
"ActionType": "ThumbnailCreation",
"Description": "Create a square avatar from the uploaded photo",
"Parameters": {
"File": "Photo",
"OutputFolder": "Profiles/",
"Name": "[User:UserID]-avatar",
"Width": "200",
"Height": "200",
"Crop": true,
"Stretch": false,
"Horizontal": "Center",
"Vertical": "Top",
"Compression": "85",
"tokenName": "Avatar"
}
}
2. Preview with a fixed width
This action makes a preview 400 pixels wide, keeping the image's proportions, and never enlarges smaller images.
{
"Title": "Create Thumbnail",
"ActionType": "ThumbnailCreation",
"Description": "Create a 400px wide preview",
"Parameters": {
"File": "ProductImage",
"OutputFolder": "Products/Previews/",
"Name": "[ProductId]-preview",
"Width": "400",
"Height": "",
"Crop": false,
"Stretch": false,
"tokenName": "Preview"
}
}
Revised 09/26/2026