|image_aplatir

Change image format and manage transparency.

The image_aplatir function performs two operations:

  • it saves an image in a predefined format (e.g. transforming a PNG image into a GIF image);
  • it manages transparency : either replaces the transparent areas with a colour, or preserve transparency.

For example:

[(#TITRE
     |image_typo{police=stencil.ttf,couleur=000000,taille=40}
     |image_aplatir{gif,ff0000})]</code>

The title transformed into a typographic image is a PNG file with transparent areas. Running this image through the image_aplatir filter turns it into a GIF, replacing the transparent areas with red (ff0000).

The function accepts as parameters, in order:

  • the format (gif, jpg, png, webp),
  • the background colour,
  • the compression quality (32, 64, or 128 for gif and from 0 to 100 for jpg)
  • transparency preservation (0 or 1): when this parameter is 1, the transparency of the gif or webp is preserved and the background color isnt used.

For example:
In a DOCUMENTS loop,

[(#FICHIER|image_aplatir{gif,ffffff,128,1})]

will convert the image to a good quality GIF by forcing the background to be transparent.

Author jack Published : Updated : 22/02/24

Translations : English, français