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

Stereo image

Composites two images


( Composites two images and produces a single image that is the composite of a left and right image of a stereo pair. )

Strip image

Strips an image of all profiles and comments.

Strip image example
$im = new Imagick($input);
$im->stripImage();
$im->swirlImage( 100 );
$im->writeImage('stripImage.jpg'); 
$im->destroy();

Swirl image

Swirls the pixels about the center of the image.

Swirl image example
$im = new Imagick($input);
$im->swirlImage( 50 );
$im->writeImage('swirlImage.jpg'); 
$im->destroy();

( Where degrees indicates the sweep of the arc through which each pixel is moved. You get a more dramatic effect as the degrees move from 1 to 360. )

Texture image

Repeatedly tiles the texture image across and down the image canvas.

Texture image example
$im = new Imagick($input);
$texture = new Imagick('bricks.png');
$im = $im->textureImage( $texture );
$im->writeImage( 'textureImage.png');
$im->destroy();

( The texture part is working but the transparency of the texture is being lost. )

Threshold image

Changes the value of individual pixels based on the intensity of each pixel compared to threshold.

Threshold image example
$im = new Imagick($input);
$im->thresholdImage( 5000 );
$im->writeImage('thresholdImage.jpg'); 
$im->destroy();

( The result is a high-contrast, two color image. )

Thumbnail image

Changes the size of an image

Thumbnail image example
$im = new Imagick( $input );
$im->thumbnailImage( 150, 150, TRUE );
$im->writeImage( "thumbnailImage.jpg" );
$im->destroy();

( Changes the size of an image to the given dimensions and removes any associated profiles. The goal is to produce small low cost thumbnail images suited for display on the Web. If TRUE is given as a third parameter then columns and rows parameters are used as maximums for each side. Both sides will be scaled down until the match or are smaller than the parameter given for the side. )

Tint image

Applies a color vector to each pixel in the image.

Tint image example
$im = new Imagick($input);
$im->tintImage( blue, 80 );
$im->writeImage( "tintImage.jpg" );
$im->destroy();

( The length of the vector is 0 for black and white and at its maximum for the midtones. The vector weighing function is f(x)=(1-(4.0*((x-0.5)*(x-0.5)))). )

Transform image

A convenience method for setting crop size and the image geometry from strings.

Transform image example
$im = new Imagick( $input );
$image = $im->transformImage( '150x150', '100x100' );
$image->writeImage( "transformImage.jpg" );
$image->destroy();

Transparent paint image

Paints pixels matching the target color transparent.

Transparent paint image example
$im = new Imagick($input);
$im->transparentPaintImage( '#850d17', 0, 20, FALSE );
$im->writeImage('transparentPaintImage.jpg'); 
$im->destroy();

( NOT WORKING AS EXPECTED )

Transpose image

Creates a vertical mirror image by reflecting the pixels around the central x-axis while rotating them 90-degrees.

Transpose image example
$im = new Imagick( $input );
$im->transposeImage();
$im->writeImage( "transposeImage.jpg" );
$im->destroy();

Transverse image

Creates a horizontal mirror image by reflecting the pixels around the central y-axis while rotating them 270-degrees.

Transverse image example
$im = new Imagick( $input );
$im->transverseImage();
$im->writeImage( "transverseImage.jpg" );
$im->destroy();

Trim image

Remove edges that are the background color from the image.

Trim image example
$im = new Imagick( 'borderImage.jpg' );
$im->trimImage( 0 );
$im->writeImage( "trimImage.jpg" );
$im->destroy();

( Not working as expected - only trims the bottom edge and then not fully. )

Unique image colors

Discards all but one of any pixel color.

Unique image colors example
$im = new Imagick( $input );
$im->uniqueImageColors();
$im->resizeImage( 200, 50, imagick::FILTER_LANCZOS, FALSE );
$im->writeImage( "uniqueImageColors.jpg" );
$im->destroy();

( Resized to fit on the page. )

Unsharp mask image

Sharpens an image.

Unsharp mask image example
$im = new Imagick( $input );
$im->unsharpMaskImage(0 , 0.5 , 1 , 0.05);
$im->writeImage( "unsharpMaskImage.jpg" );
$im->destroy();

( We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and Imagick::UnsharpMaskImage() selects a suitable radius for you. )