Imagick functions page 1

Adaptive blur image
Adds an adaptive blur filter to image.
Adaptive blur image example

bool adaptiveBlurImage ( float $radius , float $sigma [, int $channel = Imagick::CHANNEL_DEFAULT ] )

<?php 
$im 
= new Imagick($input);
$im->adaptiveBlurImage(43);
$im->writeImage('adaptiveBlurImage.jpg'); 
$im->destroy();
 
?>


The intensity of an adaptive blur is dramatically decreased at edge of the image, whereas a standard blur is uniform across the image.
Adaptive resize image
Adaptively resize image with data-dependent triangulation.
Adaptive resize image example

bool Imagick::adaptiveResizeImage ( int $columns , int $rows [, bool $bestfit = false ] )

<?php 
$im 
= new Imagick($input);
$im->adaptiveResizeImage(200150);
$im->writeImage('adaptiveResizeImage.jpg'); 
$im->destroy();
 
?>


Avoids blurring across sharp color changes. Most useful when used to shrink images slightly to a slightly smaller "web size"; may not look good when a full-sized image is adaptively resized to a thumbnail.
Adaptive threshold image
Selects an individual threshold for each pixel based on the range of intensity values in its local neighborhood.
Adaptive threshold image example

bool Imagick::adaptiveThresholdImage ( int $width , int $height , int $offset )

<?php 
$im 
= new Imagick($input);
$im->adaptiveThresholdImage(211);
$im->writeImage('adaptiveThresholdImage.jpg'); 
$im->destroy();
 
?>


This allows for thresholding of an image whose global intensity histogram doesn't contain distinctive peaks.
Adaptively sharpen image
Adaptively sharpen the image by sharpening more intensely near image edges and less intensely far from edges.
Adaptively sharpen image example

bool Imagick::adaptiveSharpenImage ( float $radius , float $sigma [, int $channel = Imagick::CHANNEL_DEFAULT ] )

<?php 
$im 
= new Imagick($input);
$im->adaptiveSharpenImage(43);
$im->writeImage('adaptiveSharpenImage.jpg'); 
$im->destroy();
 
?>
Add image
Adds new image to Imagick object from the current position of the source object.
The combine part is not working


bool addImage ( Imagick $source )

<?php 
$im 
= new Imagick ();
$im->newImage(200150, new ImagickPixel('transparent'));
$imr = new Imagick('separateImagechannel_r.jpg');
$imb = new Imagick('separateImagechannel_g.jpg' );
$img = new Imagick('separateImagechannel_b.jpg');
$im->addimage($imr);
$im->addimage($imb);
$im->addimage($img);
$im->flattenImages(); 
$im $im->combineImagesImagick::CHANNEL_ALL );
$im->writeImage('combineImages.jpg'); 
$im->destroy();
 
?>


After the operation iterator position is moved at the end of the list.
The combine part is not working
Add noise image
Adds random noise to the image.
Add noise image example

bool addNoiseImage ( int $noise_type [, int $channel = Imagick::CHANNEL_DEFAULT ] )

<?php 
$im 
= new Imagick($input);
$im->addNoiseImageImagick::NOISE_IMPULSE );
$im->writeImage('addNoiseImage.jpg'); 
$im->destroy();
 
?>
Affine transform image
Transforms an image as dictated by the affine matrix.
Affine transform image example

bool affineTransformImage ( ImagickDraw $matrix )

<?php 
$matrix 
= array( 'sx' => 0.0'rx' => 4.0'ry' => 0.0'sy' => 2.0'tx' => 0.0'ty' => 6.0 );
$im = new Imagick($input);
$draw = new ImagickDraw();
$draw->affine$matrix );
$im->affineTransformImage$draw );
$im->writeImage('affineTransformImage.jpg'); 
$im->destroy();
 
?>


No noticable effect
Animate images
This method animates the image onto a local or remote X server.
None



This method animates the image onto a local or remote X server and rarly used with php. Not available on Windows.
Annotate image
Annotates an image with text.
Annotate image example

bool annotateImage ( ImagickDraw $draw_settings , float $x , float $y , float $angle , string $text )

<?php 
// Create a new imagick objects
$im = new Imagick($input);
$draw = new ImagickDraw();

// Setup the font
$draw->setFont('arial.ttf');
$draw->setFontSize35 );

// Set the colour for the text and write the text
$fillcolor = new ImagickPixel"white" );
$draw->setFillColor$fillcolor );
$draw->setGravityImagick::GRAVITY_CENTER );
$im->annotateImage$draw000"Rubblewebs" );

// Save the image
$im->writeImage"annotateImage.jpg");

// Cleanup
$im->destroy();
 
?>
Append images
Append a set of images into one larger image.
Append images example

Imagick appendImages ( bool $stack = false )

<?php 
$im 
= new Imagick();
$im->readImage($input);
$im->readImage('addNoiseImage.jpg');
$im->readImage('adaptiveBlurImage.jpg');
$im->resetIterator();
$appended $im->appendImages(TRUE);
$appended->writeImage('appendImages.jpg'); 
$appended->destroy();
 
?>


TRUE = vertical, FALSE = horizontal
Average images
Average a set of images.
Average images example

Imagick averageImages ( void )

<?php 
$im 
= new Imagick();
$im->readImage('annotateImage.jpg');
$im->readImage('addNoiseImage.jpg');
$im->readImage('adaptiveBlurImage.jpg');
$im->resetIterator();
$average $im->averageImages();
$average->writeImage('averageImages.jpg'); 
$average->destroy();
 
?>
Black threshold image
Forces all pixels below the threshold into black while leaving all pixels above the threshold unchanged.
Black threshold image example

bool blackThresholdImage ( mixed $threshold )

<?php 
$im 
= new Imagick($input);
$im->blackThresholdImageRed );
$im->writeImage('blackThresholdImage.jpg'); 
$im->destroy();
 
?>


Similar to thresholdImage()
Blur image
Adds blur filter to image.
Blur image example

bool blurImage ( float $radius , float $sigma [, int $channel ] )

<?php 
$im 
= new Imagick($input);
$im->blurImage4);
$im->writeImage('blurImage.jpg'); 
$im->destroy();
 
?>


Optional third parameter to blur a specific channel.
Border image
Surrounds the image with a border of the color defined by the bordercolor ImagickPixel object.
Border image example

bool borderImage ( mixed $bordercolor , int $width , int $height )

<?php 
$im 
= new Imagick($input);
$im->borderImageBlack510 );
$im->writeImage('borderImage.jpg'); 
$im->destroy();
 
?>