Rubblewebs

THESE CODES ARE PROVIDED FOR AN EXAMPLE OF HOW TO USE IMAGEMAGICK WITH PHP. CARE SHOULD BE TAKEN WHEN ACCEPTING USER INPUT.

I TAKE NO RESPONSABILTY FOR ANY PROBLEMS THAT MAY OCCURE WHEN USING ANY OF THIS CODE.

IT IS UP TO YOU TO SECURE THE CODE AND VALIDATE USER INPUT.

Imagick Functions page: 1

Adaptive blur image

Adds an adaptive blur filter to image.

Adaptive blur image example
$im = new Imagick($input);
$im->adaptiveBlurImage(4, 3);
$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
$im = new Imagick($input);
$im->adaptiveResizeImage(200, 150);
$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
$im = new Imagick($input);
$im->adaptiveThresholdImage(2, 1, 1);
$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
$im = new Imagick($input);
$im->adaptiveSharpenImage(4, 3);
$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

$im = new Imagick ();
$im->newImage(200, 150, 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->combineImages( Imagick::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
$im = new Imagick($input);
$im->addNoiseImage( Imagick::NOISE_IMPULSE );
$im->writeImage('addNoiseImage.jpg'); 
$im->destroy();

Affine transform image

Transforms an image as dictated by the affine matrix.

Affine transform image example
$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.


( 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
// Create a new imagick objects
$im = new Imagick($input);
$draw = new ImagickDraw();

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

// Set the colour for the text and write the text
$fillcolor = new ImagickPixel( "white" );
$draw->setFillColor( $fillcolor );
$draw->setGravity( Imagick::GRAVITY_CENTER );
$im->annotateImage( $draw, 0, 0, 0, "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
$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
$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
$im = new Imagick($input);
$im->blackThresholdImage( Red );
$im->writeImage('blackThresholdImage.jpg'); 
$im->destroy();

( Similar to thresholdImage() )

Blur image

Adds blur filter to image.

Blur image example
$im = new Imagick($input);
$im->blurImage( 4, 3 );
$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
$im = new Imagick($input);
$im->borderImage( Black, 5, 10 );
$im->writeImage('borderImage.jpg'); 
$im->destroy();