imagefilter

(PHP 5)

imagefilter --  Applies a filter to an image

Description

bool imagefilter ( resource src_im, int filtertype [, int arg1 [, int arg2 [, int arg3]]] )

imagefilter() applies the filter filtertype to the image, using arg1, arg2 and arg3 where necessary.

filtertype can be one of the following:

Nota: Questa funzione รจ disponibile soltanto se il PHP ` compilato con la libreria GD allegata.

Restituisce TRUE in caso di successo, FALSE in caso di fallimento.

Esempio 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);
?>

Esempio 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);
?>

Esempio 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);
?>

Hosting by: hurra.com
Generated: 2007-01-26 17:56:43