imagefilter() applies the given filter
filtertype on the image.
Список параметров
image
Ресурс изображения, полученный одной из функций создания изображений,
например, такой как imagecreatetruecolor().
filtertype
filtertype can be one of the following:
IMG_FILTER_NEGATE: Reverses all colors of
the image.
IMG_FILTER_GRAYSCALE: Converts the image into
grayscale.
IMG_FILTER_BRIGHTNESS: Changes the brightness
of the image. Use arg1 to set the level of
brightness.
IMG_FILTER_CONTRAST: Changes the contrast of
the image. Use arg1 to set the level of
contrast.
IMG_FILTER_COLORIZE: Like
IMG_FILTER_GRAYSCALE, except you can specify the
color. Use arg1, arg2 and
arg3 in the form of
red, blue,
green and arg4 for the
alpha channel. The range for each color is 0 to 255.
IMG_FILTER_EDGEDETECT: Uses edge detection to
highlight the edges in the image.
IMG_FILTER_EMBOSS: Embosses the image.
IMG_FILTER_GAUSSIAN_BLUR: Blurs the image using
the Gaussian method.
IMG_FILTER_SELECTIVE_BLUR: Blurs the image.
IMG_FILTER_MEAN_REMOVAL: Uses mean removal to
achieve a "sketchy" effect.
IMG_FILTER_SMOOTH: Makes the image smoother.
Use arg1 to set the level of smoothness.
IMG_FILTER_PIXELATE: Applies pixelation effect
to the image, use arg1 to set the block size
and arg2 to set the pixelation effect mode.
arg1
IMG_FILTER_BRIGHTNESS: Brightness level.
IMG_FILTER_CONTRAST: Contrast level.
IMG_FILTER_COLORIZE: Значение красного компонента цвета.
IMG_FILTER_SMOOTH: Smoothness level.
IMG_FILTER_PIXELATE: Block size in pixels.
arg2
IMG_FILTER_COLORIZE: Значение зеленого компонента цвета.
IMG_FILTER_PIXELATE: Whether to use advanced pixelation
effect or not (defaults to FALSE).
arg3
IMG_FILTER_COLORIZE: Значение синего компонента цвета.
arg4
IMG_FILTER_COLORIZE: Alpha channel, A value
between 0 and 127. 0 indicates completely opaque while 127 indicates
completely transparent.
Возвращаемые значения
Возвращает TRUE в случае успешного завершения или FALSE в случае возникновения ошибки.
Список изменений
Версия
Описание
5.3.0
Pixelation support (IMG_FILTER_PIXELATE) was added.
5.2.5
Alpha support for IMG_FILTER_COLORIZE was added.
Примеры
Пример #1 imagefilter() grayscale example
<?php $im = imagecreatefrompng('dave.png');
if($im && imagefilter($im, IMG_FILTER_GRAYSCALE)) { echo 'Image converted to grayscale.';
<?php // Define our negate function so its portable for // php versions without imagefilter() function negate($im) { if(function_exists('imagefilter')) { return imagefilter($im, IMG_FILTER_NEGATE); }
<?php // Load the PHP logo, we need to create two instances // to show the differences $logo1 = imagecreatefrompng('./php.png'); $logo2 = imagecreatefrompng('./php.png');
// Create the image instance we want to show the // differences on $output = imagecreatetruecolor(imagesx($logo1) * 2, imagesy($logo1));
// Apply pixelation to each instance, with a block // size of 3 imagefilter($logo1, IMG_FILTER_PIXELATE, 3); imagefilter($logo2, IMG_FILTER_PIXELATE, 3, true);