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. The range for the brightness is -255 to 255.
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, green,
blue 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: Red 컴포넌트 값.
IMG_FILTER_SMOOTH: Smoothness level.
IMG_FILTER_PIXELATE: Block size in pixels.
arg2
IMG_FILTER_COLORIZE: Green 컴포넌트 값.
IMG_FILTER_PIXELATE: Whether to use advanced pixelation
effect or not (defaults to FALSE).
arg3
IMG_FILTER_COLORIZE: Blue 컴포넌트 값.
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.
예제
Example #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);