Fixed image size in TYPO3

Sometimes it happens that you want to have a certain image size and also a certain aspect ratio of the images when outputting them on the website, no matter which image the editor selects. This is often the case, for example, when you want to display a list of news articles with a preview image. It would probably look strange if the images were of different sizes, sometimes portrait and sometimes landscape, or had different aspect ratios.

But fortunately TYPO3 offers the "crop-scaling" function for this.

This means that the images are first scaled to the correct size without distorting them and if the aspect ratio does not fit, the images are cropped either top & bottom or left & right so that the desired aspect ratio is correct.

Cropping is done by default starting from the centre of the image. However, this can lead to the heads of the people in the picture being cut off. Especially if, f.e. you "crop" a portrait in portrait format to a landscape format.

This can (often) be prevented by moving the starting point of the cropping to the upper third of the image, because this is where the heads are usually located. 
To do this in TYPO3, you can specify a percentage offset (-100 ... +100) starting from the centre.

file {
    width = 420c
    height = 280c-33
}

With this setting, the width is first scaled to 420px and then cropped if necessary - starting from the centre (as no offset is specified). 

The height is scaled to 280px and if necessary cropped at 33% above the centre. Shifting the starting point upwards by 33% means that more is cropped at the bottom than at the top, so hopefully no one will be decapitated ;-)

 

More information in the TYPO3 documentation: 
https://docs.typo3.org/m/typo3/reference-typoscript/10.4/en-us/Functions/Imgresource.html?highlight=crop#width

Comments

No Comments

Write comment

* These fields are required