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

Charcoal image

Simulates a charcoal drawing.

Charcoal image example
$im = new Imagick($input);
$im->charcoalImage( 1, 2 );
$im->writeImage('charcoalImage.jpg'); 
$im->destroy();

Chop image

Removes a region of an image and collapses the image to occupy the removed portion.

Chop image example
$im = new Imagick($input);
$im->chopImage( 50, 50, 80, 50 );
$im->writeImage('chopImage.jpg'); 
$im->destroy();

Clear

Clears all resources associated to Imagick object

Clear example
edgeImage( 0.5 ); 
$im->writeImage('clear.jpg');  
$im->clear(); 
?> 

Clip image

Clips along the first path from the 8BIM profile, if present.

Clip path image

Clips along the named paths from the 8BIM profile, if present.


( Later operations take effect inside the path. It may be a number if preceded with #, to work on a numbered path, e.g., "#1" to use the first path. )

Clone

Makes an exact copy of the Imagick object.

Clone example
$im = new Imagick($input);
$shadow = $im->clone(); 
$shadow->setImageBackgroundColor( new ImagickPixel( 'black' ) ); 
$shadow->shadowImage( 80, 3, 5, 5 ); 
$shadow->compositeImage( $im, Imagick::COMPOSITE_OVER, 0, 0 ); 
$shadow->writeImage( "clone.png" );
$shadow->destroy();

Clut image

Replaces colors in the image from a color lookup table.

Clut image example
$im = new Imagick($input);
$clut = new Imagick('gradient.png');
$im->clutImage( $clut );
$im->writeImage('clutImage.jpg'); 
$im->destroy();

( Optional second parameter to replace colors in a specific channel. This method is available if Imagick has been compiled against ImageMagick version 6.3.6 or newer. )

Coalesce images

Composites a set of images while respecting any page offsets and disposal methods.


( GIF, MIFF, and MNG animation sequences typically start with an image background and each subsequent image varies in size and offset. Returns a new Imagick object where each image in the sequence is the same size as the first and composited with the next image in the sequence. )

Color floodfill image

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

Color floodfill image example
$im = new Imagick('charcoalImage.jpg');
$im->colorFloodfillImage( Red, 0, white, 52, 35 );
$im->writeImage('colorFloodfillImage.jpg'); 
$im->destroy();

Colorize image

Blends the fill color with each pixel in the image.

Colorize image example
$im = new Imagick($input);
$im->colorizeImage( '#0000b0', 0.5 );
$im->writeImage('colorizeImage.jpg'); 
$im->destroy();

Combine images

Combines one or more images into a single image.

Combine images example
$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();

( The grayscale value of the pixels of each image in the sequence is assigned in order to the specified channels of the combined image. The typical ordering would be image 1 => Red, 2 => Green, 3 => Blue, etc.
God knows what this is supposed to mean: To apply to more than one channel, combine channeltype constants using bitwise operators. )

Comment image

Adds a comment to your image.

Comment image example
$im = new Imagick($input);
$im->commentImage( 'Rubblewebs' );
$im->writeImage('commentImage.jpg'); 
$im->destroy();

( The comment is within the image data. )

Compare Image channels

Compares one or more images and returns the difference image.

Compare image layers

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