SPIP
Article proposé
L’article « |image_aplatir
(SPIP) » est proposé
à la publication depuis le jeudi 8 décembre 2022.
|image_aplatir
jeudi 8 décembre 2022 , par jack
Remove transparency and force image format
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 removes the transparency information, and replaces the transparent
areas with a colour.
For example :
[
(
#TITRE
|image_typo
{police=stencil.ttf,couleur=000000,taille=40}
|image_aplatir
{gif,ff0000}
)
]
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 is preserved.
**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.
P.-S.
See also Automatic image processing
(SPIP)
— Envoyé par SPIP (https://www.spip.net/)