resizeImage
A logic command for reducing the size of an image File.
While a large image can easily be scaled to look smaller on a document, the data behind the image is still that of a large image, increasing the document's file size. Large images may also slow down the evaluation of commands using them. This command makes it possible to resize an excessively large image to the size it is actually needed at, thereby increasing performance and reducing the file size of the result document.
Attributes
value | ||
---|---|---|
Required | Value type | EL-evaluated |
Yes | File | Yes |
Defines the image that will be resized. The resolved value is expected to be an image File of PNG, GIF, JPEG or BMP format. |
var | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String | No |
Defines the name of a variable holding the resized image File. If not defined, the File to be resized will become the resized File and no new variable is created. |
height | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String, Number | Yes |
Defines a new height for the image. The resolved value can define the height in two ways:
If the defined height value is higher than the original height of the image, the height is set to that original height. Either this attribute or If not defined, the image's new height is calculated based on the resolved value of |
width | ||
---|---|---|
Required | Value type | EL-evaluated |
No | String, Number | Yes |
Defines a new width for the image. The resolved value can define the width in two ways:
If the defined width value is higher than the original width of the image, the width is set to that original width. Either this attribute or If not defined, the image's new width is calculated based on the resolved value of |
Examples
Unlike many other commands with the var
attribute, resizeImage
doesn't actually require a value for it - in fact, it is better to leave it undefined in case your logic has no need for the image in its original size. Doing so modifies the image File value that is being resized so that it itself becomes the resized image. At minimum resizeImage
therefore needs two attributes defined, value
and either width
or height
. The following causes the File variable "image" to become 50% smaller in both height and width:
<resizeImage value="${image}" height="50%">
Leaving either height
or width
undefined is an easy way to resize the image without affecting its aspect ratio.