|image_recadre

The filter |image_recadre crop an image to absolute dimensions or proportions.

Uses

This filter can be applied to

Crop to absolute dimensions

The arguments are:

|image_recadre{width, height, position, background colour}

  1. width;
  2. height;
  3. position (optional) :
    • `center`, `left`, `right`, `top`, `bottom`;
    • or combinations of several `top left`;
    • or an indication in pixels from a position `top=50` or composed `top=40 left=50`;
    • or the name of a special function that will calculate and return the desired position.
  4. the background colour (optional) argument is useful if you enlarge the image.

Examples with absolute dimensions

[(#FICHIER|image_recadre{800, 400})]
[(#LOGO_ARTICLE|image_recadre{800, 400, center})]
[(#LOGO_RUBRIQUE|image_recadre{800, 400, center, black})]
[(#FICHIER|image_recadre{90,90,center})]
|image_recadre{90,90,center}
|image_recadre90,90,center

Crop the original image into a square of 90 px width and height based on the centre of the image.

|image_recadre also allows to enlarge an image file, the background is then specified by a colour or ’transparent’ as the 4th argument:

[(#FICHIER|image_recadre{500,300,'top left','#663399'})]
|image_recadre{500,300,'top left','#663399'}
|image_recadre500,300,’top left’,’#663399’

Crop to proportions

(Since SPIP 3.0.19 )

Arguments are:

|image_recadre{proportions, +|-, position, background colour}

  1. proportions : ratio width:height required;
  2. +|- : ’+’ to enlarge with stripes, ’-’ to reduce. (if ’-’ is applied, it is equivalent to |image_passe_partout);
  3. position (optional) : Cutting position indication:
    • `center`, `left`, `right`, `top`, `bottom`;
    • or combinations of several `top left`;
    • or an indication in pixels from a position `top=50` or composed `top=40 left=50`;
    • or the name of a special function that will calculate and return the desired position.
  4. background colour (optional), argument is useful if you enlarge the image.

Examples with proportions

[(#FICHIER|image_recadre{16:9, '-'})]
[(#LOGO_BREVE|image_recadre{1:1, '-', center})]
[(#FICHIER|image_recadre{16:9, -, top left})]
[(#FICHIER|image_recadre{16:9, -, top=40 left=20})]
[(#FICHIER|image_recadre{16:9, +, center, white})]
|image_recadre{16:9,'-'}
|image_recadre16:9,’-’

Allows you to have a logo in 16:9 format with as little cropping of the image as possible.
This keeps the image as large as possible while keeping to a proportion.

Example

[(#LOGO_ARTICLE|image_recadre{1:1,-,center top})]
|image_recadre{1:1,'-','center top'}
|image_recadre1:1,’-’,’center top’

See also

The filters

The article on the Automatic image processing, also detailing many other image filters.

Author jack Published : Updated : 13/05/20

Translations : English, Español, français, Nederlands