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

Is similar

Checks the distance between the color described by this ImagickPixel object

The colours are the same within the tolerance

$im = new Imagick($input);
$pixel = $im->getImagePixelColor( 78, 22 );
$compair = new ImagickPixel();
$compair->setColor("rgb(105,134,6)");
$output = $compair->isSimilar($pixel, 0.2);
if ( $output ) { echo "
The colours are the same within the tolerance";} else echo "
The colours are Different"; $im->destroy();

( Checks the distance between the color described by this ImagickPixel object and that of the provided object, by plotting their RGB values on the color cube. If the distance between the two points is less than the fuzz value given, the colors are similar. )

Label image

Adds a label to an image.

levelImage

Adjusts the levels of an image by scaling the colors falling between specified white and black points to the full available quantum range.

levelImage example
$im = new Imagick($input);
$im->levelImage (100, 1.0, 65000); 
$im->writeImage('levelImage.jpg'); 
$im->destroy();

( The parameters provided represent the black, mid, and white points. The black point specifies the darkest color in the image. Colors darker than the black point are set to zero. Mid point specifies a gamma correction to apply to the image. White point specifies the lightest color in the image. Colors brighter than the white point are set to the maximum quantum value. )

Linear stretchImage

Stretches with saturation the image intensity.

Linear stretchImage example
$im = new Imagick($input);
$im->linearStretchImage ( 1, '2%' ); 
$im->writeImage('linearStretchImage.jpg'); 
$im->destroy();

Liquid rescale image

This method scales the images using liquid rescaling method.


( This method is an implementation of a technique called seam carving. In order for this method to work as expected ImageMagick must be compiled with liblqr support. )

Magnify image

Is a convenience method that scales an image proportionally to twice its original size.

Magnify image example
$im = new Imagick($input);
$im->magnifyImage(); 
$im->writeImage('magnifyImage.jpg'); 
$im->destroy();

Map image

Replaces the colors of an image with the closest color from a reference image.

Map image example
$im = new Imagick ($input);
$im1 = new Imagick ('solarizeImage.jpg');
$im->mapImage( $im1, 10 );
$im->writeImage('mapImage.jpg'); 
$im->destroy();

Matte flood fill image

Changes the transparency value of any pixel that matches target and is an immediate neighbor.

Matte flood fill image example
$im = new imagick( $image );
$bordercolour = '#f42a44';
$im->matteFloodfillImage(0.1, 20028, $bordercolour, 30, 20);
$im->writeImage('matteFloodfillImage.png'); 
$im->destroy();

( If the method FillToBorderMethod is specified, the transparency value is changed for any neighbor pixel that does not match the bordercolor member of image.
The fuzz in the quantum range so if you use Q16 Quantum is 65535 )

Median filter image

Applies a digital filter that improves the quality of a noisy image.

Median filter image example
$im = new Imagick($input);
$im->medianFilterImage( 5 );
$im->writeImage('medianFilterImage.jpg'); 
$im->destroy();

( Each pixel is replaced by the median in a set of neighboring pixels as defined by radius. )

Merge image layers

Merges image layers into one.


( This method is useful when working with image formats that use multiple layers such as PSD. The merging is controlled using the layer_method which defines how the layers are merged. )

Minify image

Is a convenience method that scales an image proportionally to one-half its original size

Minify image example
$im = new Imagick($input);
$im->minifyImage();
$im->writeImage('minifyImage.jpg'); 
$im->destroy();

( )

modulateImage

Lets you control the brightness, saturation, and hue of an image.

modulateImage example
$im = new Imagick($input);
$im->modulateImage(100, 100, 80);
$im->writeImage('modulateImage.jpg'); 
$im->destroy();

( Hue is the percentage of absolute rotation from the current position. For example 50 results in a counter-clockwise rotation of 90 degrees, 150 results in a clockwise rotation of 90 degrees, with 0 and 200 both resulting in a rotation of 180 degrees. )

Montage image

Creates a composite image by combining several separate images.


( The images are tiled on the composite image with the name of the image optionally appearing just below the individual tile. )

Morph images

Method morphs a set of images.


( Both the image pixels and size are linearly interpolated to give the appearance of a meta-morphosis from one image to the next. )