Image dimensions

KCM Core calculates the dimensions of an image automatically based on the properties of the image. This calculation can be modified by providing the width and/or height parameters to override the corresponding dimensions. The following requirements must be met:

  • No dimensions are specified: the size is calculated based on the number of pixels and the DPI property of the image.
  • One dimension is specified: the other dimension is calculated relative to the original dimensions of the image.
  • Both dimensions are specified: the image is resized to fit within a box with the specified dimensions. Both dimensions are resized by the same scale to maintain the aspect ratio of the image.

The parameter dpi can be used to override the DPI property of the image if neither width nor height is specified.

The parameter keepaspect can be used to control the resizing of the image if both dimensions are specified. If the parameter is set to N, the image is resized to fill the box and may cause the image to stretch in one direction. If this parameter is set to Y or omitted, the aspect ratio of the image is maintained, and the image is resized to fill the bounding box optimally.

Examples are provided here.

 @(insert_image (logo)) 
	 

This example uses the native dimensions of the image.

 @(insert_image (logo; width:="4cm";
height:="2cm"))

The preceding example resizes the image to fit within a 4cm x 2cm box. An image of 100x200 pixels would be resized to 1cm x 2cm.

 @(insert_image (logo; width:="4cm";
height:="2cm"; keepaspect:="N"))

The preceding example resizes and stretches the image to fill a 4cm x 2cm box. An image of 100x200 pixels would be stretched to 4cm x 2cm.