(PHP 5)
imagefilter — Applies a filter to an image
imagefilter() applies the given filter filtertype on the image .
O resursă - imagine, întoarsă de una din funcţiile de creare a imaginilor, cum ar fi imagecreatetruecolor().
filtertype can be one of the following:
Întoarce valoarea TRUE în cazul succesului sau FALSE în cazul eşecului.
Versiunea | Descriere |
---|---|
5.2.5 | Alpha support for IMG_FILTER_COLORIZE was added. |
Example#1 imagefilter() grayscale example
<?php
$im = imagecreatefrompng('dave.png');
if ($im && imagefilter($im, IMG_FILTER_GRAYSCALE)) {
echo 'Image converted to grayscale.';
imagepng($im, 'dave.png');
} else {
echo 'Conversion to grayscale failed.';
}
imagedestroy($im);
?>
Example#2 imagefilter() brightness example
<?php
$im = imagecreatefrompng('sean.png');
if ($im && imagefilter($im, IMG_FILTER_BRIGHTNESS, 20)) {
echo 'Image brightness changed.';
imagepng($im, 'sean.png');
} else {
echo 'Image brightness change failed.';
}
imagedestroy($im);
?>
Example#3 imagefilter() colorize example
<?php
$im = imagecreatefrompng('philip.png');
/* R, G, B, so 0, 255, 0 is green */
if ($im && imagefilter($im, IMG_FILTER_COLORIZE, 0, 255, 0)) {
echo 'Image successfully shaded green.';
imagepng($im, 'philip.png');
} else {
echo 'Green shading failed.';
}
imagedestroy($im);
?>
Notă: Această funcţie este disponibilă numai dacă PHP este compilat cu versiunea bibliotecii GD furnizată împreună cu PHP.