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: 3

Compare images

Returns an array containing a reconstructed image and the difference between images.

Composite image

Composite one image onto another at the specified offset.

Composite image example
$imagick = new Imagick($input);
$imagick->blurImage(0,.5);
$overlay = new Imagick($image);
$imagick->compositeImage($overlay, imagick::COMPOSITE_SOFTLIGHT, 0, 0);
$imagick->writeImage("compositeImage.jpg");

( Softlight effect )

Construct

Creates an Imagick instance for a specified image or set of images.

Contrast image

Enhances the intensity differences between the lighter and darker elements of the image.

Contrast image example
$im = new Imagick($input);
$im->contrastImage(5);
$im->writeImage( 'contrastImage.jpg' );
$im->destroy();

( Set sharpen to a value other than 0 to increase the image contrast otherwise the contrast is reduced. )

Contrast stretch image

Enhances the contrast of a color image by adjusting the pixels color to span the entire range of colors available.

Contrast stretch image example
$im = new Imagick($input);
$im->contrastStretchImage(.15, .05);
$im->writeImage('contrastStretchImage.jpg'); 
$im->destroy();

Convolve image

Applies a custom convolution kernel to the image.

Convolve image example
$image = new imagick( "input.jpg" ); 
$edgeArray = array(-1,-1,-1,-1,8,-1,-1,-1,-1);
$image->convolveImage ($edgeArray);
$image->thresholdImage(1);
$image->writeImage('convolveImage.jpg'); 
$image->destroy();

Crop image

Extracts a region of the image.

Crop image example
$im = new Imagick($input);
$im->cropImage( 100, 100, 60, 20 );
$im->writeImage('cropImage.jpg'); 
$im->destroy();

Crop thumbnail image

Creates a fixed size thumbnail by first scaling the image up or down and cropping a specified area from the center.

Crop thumbnail image example
$im = new Imagick($input);
$im->cropThumbnailImage( 150, 150 );
$im->writeImage('cropThumbnailImage.jpg'); 
$im->destroy();

Current

Returns reference to the current imagick object with image pointer at the correct sequence.

Cycle colormap image

Displaces an image's colormap by a given number of positions.

Cycle colormap image example
$im = new Imagick($input);
$im->cycleColormapImage(80);
$im->writeImage('cycleColormapImage.jpg'); 
$im->destroy();

( If you do this a few times, it produces a psychedelic effect. )

Decipher image

Deciphers image that has been enciphered before.

Decipher image example
$im = new Imagick('encipherImage.png');
$im->decipherImage(passkey.txt);
$im->writeImage('decipherImage.png'); 
$im->destroy();

( The image must be enciphered using encipherImage(). )

Deconstruct images

Compares each image with the next in a sequence and returns the maximum bounding region of any pixel differences it discovers.

Deconstruct images example
$im = new Imagick();
$im->readImage('addNoiseImage.jpg');
$im->readImage('adaptiveBlurImage.jpg');
$deconstruct = $im->deconstructImages ();
$deconstruct->writeImage('deconstructImages.jpg'); 
$deconstruct->destroy();

( 'Not working' )

Delete image artifact

Deletes an artifact associated with the image.


( The difference between image properties and image artifacts is that properties are public and artifacts are private. )

Deskew image

This method can be used to remove skew from for example scanned images where the paper was not properly placed on the scanning surface.

Deskew image example
Another Deskew image example
$im = new Imagick('text.png');
$im->deskewImage( 80 );
$im->writeImage( 'deskew.jpg' );
$im->destroy();