8.53 Images
8 Référence des fonctions
Manuel PHP
. Introduction . Pré-requis . Installation . Configuration à l'exécution . Types de ressources . Constantes pré-définies . Exemples . gd_info . getimagesize . image_type_to_extension . image_type_to_mime_type . image2wbmp . imagealphablending . imageantialias . imagearc . imagechar . imagecharup . imagecolorallocate . imagecolorallocatealpha . imagecolorat . imagecolorclosest . imagecolorclosestalpha . imagecolorclosesthwb . imagecolordeallocate . imagecolorexact . imagecolorexactalpha . imagecolormatch . imagecolorresolve . imagecolorresolvealpha . imagecolorset . imagecolorsforindex . imagecolorstotal . imagecolortransparent . imageconvolution . imagecopy . imagecopymerge . imagecopymergegray . imagecopyresampled . imagecopyresized . imagecreate . imagecreatefromgd . imagecreatefromgd2 . imagecreatefromgd2part . imagecreatefromgif . imagecreatefromjpeg . imagecreatefrompng . imagecreatefromstring . imagecreatefromwbmp . imagecreatefromxbm . imagecreatefromxpm . imagecreatetruecolor . imagedashedline . imagedestroy . imageellipse . imagefill . imagefilledarc . imagefilledellipse . imagefilledpolygon . imagefilledrectangle . imagefilltoborder ->imagefilter . imagefontheight . imagefontwidth . imageftbbox . imagefttext . imagegammacorrect . imagegd . imagegd2 . imagegif . imageinterlace . imageistruecolor . imagejpeg . imagelayereffect . imageline . imageloadfont . imagepalettecopy . imagepng . imagepolygon . imagepsbbox . imagepscopyfont . imagepsencodefont . imagepsextendfont . imagepsfreefont . imagepsloadfont . imagepsslantfont . imagepstext . imagerectangle . imagerotate . imagesavealpha . imagesetbrush . imagesetpixel . imagesetstyle . imagesetthickness . imagesettile . imagestring . imagestringup . imagesx . imagesy . imagetruecolortopalette . imagettfbbox . imagettftext . imagetypes . imagewbmp . imagexbm . iptcembed . iptcparse . jpeg2wbmp . png2wbmp
|
8.53.61 imagefilter()
Applique un filtre à une image
[ Exemples avec imagefilter ] PHP 5
bool
imagefilter (
resource
src_im
,
int
filtertype
,
int
arg1
,
int
arg2
,
int
arg3
)
imagefilter
applique le filtre
filtertype
à l'image en utilisant les paramètres
args1
,
args2
et
args3
lorsque
cela est nécessaire.
Le paramètre
filtertype
peut prendre l'une des valeurs suivantes :
-
IMG_FILTER_NEGATE
: renverse toutes les couleurs de l'image.
-
IMG_FILTER_GRAYSCALE
: convertit l'image en
grayscale
.
-
IMG_FILTER_BRIGHTNESS
: modifie la luminosité de
l'image. Utilisez le paramètre
args1
pour définir
la luminosité.
-
IMG_FILTER_CONTRAST
: modifie le contraste de
l'image. Utilisez le paramètre
args1
pour définir
le contraste.
-
IMG_FILTER_COLORIZE
: Identique au paramètre
IMG_FILTER_GRAYSCALE
excepté que vous pouvez spécifier
une couleur. Utilisez trois arguments séparés dans les paramètres
args1
,
args2
et
args3
sous la forme
red
,
blue
,
green
.
L'intervalle pour chaque couleur est 0 - 255.
-
IMG_FILTER_EDGEDETECT
: utilise la détection des bords
pour les mettre en évidence dans l'image.
-
IMG_FILTER_EMBOSS
: grave l'image en relief.
-
IMG_FILTER_GAUSSIAN_BLUR
: brouille l'image en utilisant la
méthode gaussienne.
-
IMG_FILTER_SELECTIVE_BLUR
: brouille l'image.
-
IMG_FILTER_MEAN_REMOVAL
: son utilisation signifie le déplacement pour réaliser un effet "peu précis".
-
IMG_FILTER_SMOOTH
: rend l'image lissoir
(
smooth
).
Utilisez le paramètre
args1
pour définir le degré
de lissoir.
| Note | |
Cette fonction n'est disponible que si
PHP
est compilé avec la version embarquée de la bibliothèque GD.
|
Cette fonction retourne
TRUE
en cas de
succès,
FALSE
en cas d'échec.
| Exemple avec imagefilter en utilisant le paramètre IMG_FILTER_GRAYSCALE |
<?php $im = imagecreatefrompng('dave.png'); if ($im && imagefilter($im, IMG_FILTER_GRAYSCALE)) { echo 'Image convertie en grayscale.'; imagepng($im, 'dave.png'); } else { echo 'La convertion en grayscale a échoué.'; }
imagedestroy($im); ?>
|
| Exemple avec imagefilter en utilisant le paramètre IMG_FILTER_BRIGHTNESS |
<?php $im = imagecreatefrompng('sean.png'); if ($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, 20)) { echo 'La luminosité de l\'image a été modifiée.'; imagepng($im, 'sean.png'); } else { echo 'Echec lors de la modification de la luminosité.'; }
imagedestroy($im); ?>
|
| Exemple avec imagefilter en utilisant le paramètre IMG_FILTER_COLORIZE |
<?php $im = imagecreatefrompng('philip.png');
/* R, G, B, donc 0, 255, 0 correspond au vert */ if ($im && imagefilter($im, IMG_FILTER_COLORIZE, 0, 255, 0)) { echo 'L\'image a été ombragée en vert avec succès.'; imagepng($im, 'philip.png'); } else { echo 'Echec lors de la modification de l\'ombrage.'; }
imagedestroy($im); ?>
|
|