imagick是一个功能强大的图像处理库。
说是翻译 其实就是简要介绍imagick 的主要功能的或者说是我觉得比较实用的功能函数的介绍 以及使用的例子。
因为本人的英语水平有限,所以采用比较通俗或者说比较贴近应用化的语言来描述。
先欣赏一组炫丽的效果:
偏置图像:
例子:
复制代码 代码如下:
ini_set('display_errors',1);
header('content-type: image/jpeg');
$image = new imagick('1.jpg');
$image->rollimage(20,39);
echo $image;
?>
thumbnailimage($width,$height) 改变图片大小
例子:
复制代码 代码如下:
ini_set('display_errors',1);
header('content-type: image/jpeg');
$image = new imagick('1.jpg');
$image->thumbnailimage(100,0);
echo $image;
?>
addnoiseimage(int $noise_type [, int $channel= imagick::channel_all ]);
功能:
adds random noise to the image
添加干扰素
复制代码 代码如下:
noise constants ( $noise_type 类型)
imagick::noise_uniform (integer)
imagick::noise_gaussian (integer)
imagick::noise_multiplicativegaussian (integer)
imagick::noise_impulse (integer)
imagick::noise_laplacian (integer)
imagick::noise_poisson (integer)
channel constants ( $channel 类型)
imagick::channel_undefined (integer)
imagick::channel_red (integer)
imagick::channel_gray (integer)
imagick::channel_cyan (integer)
imagick::channel_green (integer)
imagick::channel_magenta (integer)
imagick::channel_blue (integer)
imagick::channel_yellow (integer)
imagick::channel_alpha (integer)
imagick::channel_opacity (integer)
imagick::channel_matte (integer)
imagick::channel_black (integer)
imagick::channel_index (integer)
imagick::channel_all (integer)
例子:
复制代码 代码如下:
ini_set('display_errors',1);
header('content-type: image/jpeg');
$image = new imagick('1.jpg');
$image->thumbnailimage(100,0);
$image->addnoiseimage(imagick::noise_poisson,imagick::channel_opacity);
echo $image;
?>
annotateimage 创建文本图像 例子:
复制代码 代码如下:
$image = new imagick();
$draw = new imagickdraw();
$pixel = new imagickpixel( 'gray' );
$image->newimage(800, 75, $pixel);
$pixel->setcolor('black');
$draw->setfont('bookman-demiitalic');
$draw->setfontsize( 30 );
$image->annotateimage($draw, 10, 45, 0, 'the quick brown fox jumps over the lazy dog');
$image->setimageformat('png');
header('content-type: image/png');
echo $image;
?>
blurimage(float $radius , float $sigma [, int $channel ])
adds blur filter to image 图像模糊度处理
参数:
复制代码 代码如下:
int $channel :
imagick::channel_undefined (integer)
imagick::channel_red (integer)
imagick::channel_gray (integer)
imagick::channel_cyan (integer)
imagick::channel_green (integer)
imagick::channel_magenta (integer)
imagick::channel_blue (integer)
imagick::channel_yellow (integer)
imagick::channel_alpha (integer)
imagick::channel_opacity (integer)
imagick::channel_matte (integer)
imagick::channel_black (integer)
imagick::channel_index (integer)
imagick::channel_all (integer)
复制代码 代码如下:
ini_set('display_errors',1);
header('content-type: image/jpeg');
$image = new imagick('1.jpg');
$image->blurimage(5,3);
echo $image;
?>
borderimage ( mixed $bordercolor , int $width , int $height ) 图片边框处理
例子:
复制代码 代码如下:
ini_set('display_errors',1);
header('content-type: image/jpeg');
$image = new imagick('1.jpg');
$color=new imagickpixel();
$color->setcolor(rgb(220,220,220));
$image->borderimage($color,5,4);
$image->blurimage(5,5,imagick::channel_green);
echo $image;
?>
charcoalimage ( float $radius , float $sigma ) 图像素描处理
参数说明:
$radius :越小越薄。
$sigma: 越大 墨越深 反之。
例子:
复制代码 代码如下:
