I. Data Website
Http://cn.php.net/imagick
Http://www.imagemagick.org/script/index.php
Http://www.imagemagick.org/download/binaries/
Ii. Instance
<? PHP
// Obtain the watermark image
$ Logo = new imagick ("logo.png ");
$ Logo-> setimageresolution (0.01, 0.03 );
// Create an imagick object and obtain the source image to be processed.
$ Im = new imagick ("old_large_img_2.jpg ");
// Obtain the source image width and height
$ Srcwh = $ im-> getimagegeometry ();
// Set the proportional scaling width and height of the image.
If ($ srcwh ['width']> 710 ){
$ Srcw ['width'] = 710;
$ Srch ['height'] = $ srcw ['width']/$ srcwh ['width'] * $ srcwh ['height'];
} Else {
$ Srcw ['width'] = $ srcwh ['width'];
$ Srch ['height'] = $ srcwh ['height'];
}
// Scale by proportion
$ Im-> thumbnailimage ($ srcw ['width'], $ srch ['height'], true );
// Create a color image based on the thumbnail size
$ Canvas = new imagick ();
$ Canvas-> newimage ($ srcw ['width'], $ srch ['height'], 'black', 'jpg '); // pink, black
// Add a watermark
$ Im-> compositeimage ($ logo, imagick: composite_over, $ srcw ['width']-280, $ srch ['height']-77 );
$ Canvas-> setcompressionquality (91 );
// Merge Images
$ Canvas-> compositeimage ($ im, imagick: composite_over, 0, 0 );
// Output image
Header ("Content-Type: image/jpg ");
Echo $ canvas;
// Generate an image
$ Canvas-> writeimage ("test_img/old_large_img_2_96.jpg ");
?>
Imagick is a powerful image processing library.
It is actually a brief introduction to the main functions of imagick, or an example of functional functions that I think are more practical.
Because of my limited level of English, I use a more popular or close-to-use language to describe.
First, I would like to enjoy a set of dazzling results:
Strong>
Offset image:
Example:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->rollImage(20,39);
echo $image;
?>
Thumbnailimage($ Width, $ height) change the image size
Example:
<?php
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]);
Function:
Adds random noise to the image
Add interferon
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 type)
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)
Example:
<?php
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;
?>
AnnotateimageCreate text image
Example:
<?php
$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 blur Processing
Parameters:
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)
<?php
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) image Border Processing
Example:
<?php
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) image sketch Processing
Parameter description:
$ Radius: the smaller the image, the thinner the image.
$ Sigma: The bigger the ink, the deeper the reverse.
Example:
<?php
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->charcoalImage(0.0001,0.001);
//$image->blurImage(5,5,imagick::CHANNEL_GREEN);
echo $image;
?>
Chopimage(INT $ width, int $ height, int $ X, int $ Y)
Parameter description: deletes a certain range of image regions.
No parameter descriptions are provided.
Colorizeimage(Mixed $ colorize, mixed $ opacity) Mixed Fill color
$ Colorize color
$ Opacit transparency
Example:
<? PHP
/*
Film Effect
*/
Ini_set ('display _ errors ', 1 );
Header ('content-type: image/JPEG ');
$ Image = new imagick('1.jpg ');
$ Image-> new.image (false );
$ Image-> colorizeimage ('#000', 1.0 );
Echo $ image;
?>
Embossimage(Float $ radius, float $ sigma)
Function: it is not good to return a grayscale 3D image.
Example:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->embossImage(1,1);
echo $image;
?>
(Two images)
Flipimage(Void)
Function: creates an image reflection (vertical flip)
Example:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->flipImage();
echo $image;
?>
Flopimage(Void)
Function: horizontal image flip
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->flopImage();
echo $image;
?>
Frameimage(Mixed $ matte_color, int $ width, int $ height, int $ inner_bevel, int $ outer_bevel)
Function: Creates a 3D image border.
Parameter description:
$ Matte_color: Color
$ Inner_bevel: Internal skew of the border
$ Outer_bevel: external border skew
Example:
<?php
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->frameImage($color,11,11,1,10);
echo $image;
?>
Note:
$ Width (width) cannot be less than $ inner_bevel (inside the border skew)
Imagick: gammaimage (float $ gamma [, int $ channel = imagick: channel_all])
Function: adjusts the gray level coefficient of an image.
Parameter description:
Float $ GAMMA: gray value
$ Channel: imagick: channel_all by default
Imagick: channel_all
Example 1:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->gammaImage(30);
echo $image;
?>
Example 2:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->gammaImage(30);
echo $image;
?>
Gaussianblurimage(Float $ radius, float $ Sigma [, int $ channel = imagick: channel_all])
Function: Gaussian Blur processing is similar to photo's Gaussian blur.
Parameter description:
Float $ radius: radius of Gaussian blur, pixel, excluding the center pixel.
Float $ Sigma: Standard deviation of Gaussian, in pixels. I think this parameter is the most important.
Int $ channel: image color mode.
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->gaussianBlurImage(30,3);
echo $image;
?>
Levelimage(Float $ blackpoint, float $ gamma, float $ whitepoint [, int $ channel = imagick: channel_all])
Function: adjusts the color order of an image (adjusts the levels of an image)
Parameter description
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->levelImage(4,4,4);
echo $image;
?>
Example 2:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->levelImage(200,200,200,imagick::CHANNEL_GREEN);
echo $image;
?>
Magnifyimage(Void)
Function Description: Scale up an image by a factor of 2 (is a convenience method that scales an image proportionally to twice its original size .)
Example:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->magnifyImage ();
echo $image;
?>
Medianfilterimage(Float $ radius)
Function: the Special filter is a bit like a Photoshop color knife filter.
<?php
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->medianFilterImage(5);
echo $image;
?>
Minifyimage(Void)
Function: scale down an image by one (scales an image proportionally to half its size)
Example:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->minifyImage();
echo $image;
?>
Modulateimage(Float $ brightness, float $ saturation, float $ Hue)
Function: adjusts the brightness, saturation, and tone of an image.
Parameter description:
Float $ brightness: brightness
Float $ saturation: Saturation
Float $ hue color
Example 1:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->modulateImage(100,1,100);
echo $image;
?>
Example 2:
<?php
ini_set('display_errors',1);
header('Content-type: image/jpeg');
$image = new Imagick('1.jpg');
$image->modulateImage(250,1,250);
echo $image;
?>
Motionblurimagemotionblurimage(Float $ radius, float $ Sigma, float $ angle [, int $ channel = imagick: channel_default])
Function: simulate motion blur, similar to the dynamic blur filter function of Photoshop.
Parameter description:
Float $ radius: Gaussian radius, which does not overwrite the center pixel.
Float $ Sigma: Gaussian of standard deviation, in pixels. Important Parameters]
Float $ angle: blur angle.
Int $ channel: image color mode. The default value is imagick: channel_default.
Example 1:
<?php
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->motionBlurImage (61,10,10);
echo $image;
?>
Example 2:
<?php
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->motionBlurImage (201,10,100);
echo $image;
?>
Oilpaintimage(Float $ radius ):
Function Description: Simulate an oil painting)
Example:
<?php
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->oilPaintImage(1);
echo $image;
?>
Radialblurimage(Float $ angle [, int $ channel = imagick: channel_all])
Function: radial blurs an image)
<?php
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->radialBlurImage(30);
echo $image;
?>
Raiseimage(INT $ width, int $ height, int $ X, int $ y, bool $ raise)
Function Description: Create a 3D image button (creates a Simulated 3D button-like effect)
<?php
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->raiseImage(10,10,3,5,6);
echo $image;
?>
Source: http://blog.csdn.net/yuzhengyang0720/article/details/5967629