There are five methods to specify the resulting dimensions for an image to be resized in pixel size (the size parameters must be positive numbers or -1 number). If the value is -1, it will resize an image to the document paper dimensions. For example:
$image.setWidth($diagram.image, -1)
As shown by the example, the image will be resized to a paper width while maintaining the aspect ratio. The value -1 applies only to certain template types such as RTF, ODT, and DOCX. If the value is -2, it will resize an image to document paper bounds if and only if image bounds are larger than paper bounds. For example:
$image.setWidth($diagram.image, -2)
Using the value -2 also maintains the image aspect ratio. However, it can only be applied to certain template types such as RTF, ODT, and DOCX.
$image.setSize(image, sizeWidth, sizeHeight)
Return an image icon for an element. This method is used to resize the image to an exact size; the width and height in pixels.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | image | com.nomagic.magicreport.Image | An image object |
sizeWidth | java.lang.Integer | The width of the image in pixels. | |
sizeHeight | java.lang.Integer | The height of the image in pixels. | |
Return | - | com.nomagic.magicreport.Image | The resized image object for the element icon. |
$image.setHeight(image, size)
Return an image icon for an element. This method is used to resize the image to a specific height (in pixels), while maintaining the image aspect ratio.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | image | com.nomagic.magicreport.Image | An image object for the element icon. |
size | java.lang.Integer | The height of the image in pixels. | |
Return | - | com.nomagic.magicreport.Image | The resized image object for the element icon. |
$image.setHeight(image, size, keepRatio)
Return an image icon for an element. This method is used to resize the image to a specific height (in pixels) and to specify whether the image aspect ratio is to be maintained or not (depending on the keepRatio parameter).
Name | Type | Description | |
---|---|---|---|
Parameter(s) | image | com.nomagic.magicreport.Image | An image object for the element icon. |
size | java.lang.Integer | The height of the image in pixels. | |
keepRatio | java.lang.Boolean | A flag to maintain the image aspect ratio | |
Return | - | com.nomagic.magicreport.Image | The resized image object for the element icon. |
$image.setWidth(image, size)
Return an image icon for an element. This method is used to resize the image to a specific width (in pixels), while maintaining the image aspect ratio.
Name | Type | Description | |
---|---|---|---|
Parameter(s) | image | com.nomagic.magicreport.Image | An image object for the element icon. |
size | java.lang.Integer | The width of the image in pixels. | |
Return | - | com.nomagic.magicreport.Image | The resized image object for the element icon. |
$image.setWidth(image, size, keepRatio)
Return an image icon for an element. This method is used to resize the image to a specific width (in pixels) and to specify whether the image aspect ratio is to be maintained or not (depending on the keepRatio parameter).
Name | Type | Description | |
---|---|---|---|
Parameter(s) | image | com.nomagic.magicreport.Image | An image object for the element icon. |
size | java.lang.Integer | The width of the image in pixels. | |
keepRatio | java.lang.Boolean | A flag to maintain | |
Return | - | com.nomagic.magicreport.Image | The resized image object for the element icon. |
Use $image.setSize($diagram.image, 200, 200), for example, to resize the image’s width and height to 200 pixels. The following photos show the result.
Figure 1: Results of using the image set size function.
Use either $image.setWidth($diagram.image, 150) or $image.setWidth($diagram.image, 150, true), for example, to resize the image’s width to 150 pixels and maintain the image aspect ratio. The following photos show the result.
Figure 2: Results of using the image set width function.
Use $image.setWidth($diagram.image, 150, false), for example, to resize the image’s width to 150 pixels and ignore the image aspect ratio. The following photos show the result.
Figure 3: Results of using the image set width function.