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

Flatten images

Merges a sequence of images.

/*
$im = new Imagick($input);
$top = new Imagick('newPseudoImage.jpg');
$im->compositeImage($top, Imagick::COMPOSITE_SCREEN, 0, 0 );
$im = $im->flattenImages(); 
$im->writeImage('flattenImages.jpg'); 
$im->destroy();
*/

( This is useful for combining Photoshop layers into a single image. NOT WORKING )

Flip image

Creates a vertical mirror image by reflecting the pixels around the central x-axis.

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

Flood fill paint

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

Flood fill paint example
$im = new Imagick($input);
$im->floodfillPaintImage("Orange", 10, '#850d0f', 115, 42, FALSE);
$im->writeImage("floodfillpaint.jpg"); 
$im->destroy();

( This method is a replacement for deprecated Imagick::paintFloodFillImage().
NOT WORKING )

Flop image

Creates a horizontal mirror image by reflecting the pixels around the central y-axis.

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

Frame image

Adds a simulated three-dimensional border around the image.

Frame image example
$im = new Imagick($input);
$im->frameImage( Black, 10, 10, 5, 5 );
$im->writeImage('frameImage.jpg'); 
$im->destroy();

( The width and height specify the border width of the vertical and horizontal sides of the frame. The inner and outer bevels indicate the width of the inner and outer shadows of the frame. )

Function image

Applies an arithmetic, relational, or logical expression to an image.

My version of Imagick is to old

/*
$im->functionImage ( Imagick::FUNCTION_POLYNOMIAL, array( 4, -4, 1 ) );
*/

( Use these operators to create lighter or darker versions of an image, to increase or decrease contrast in an image, or to negate the image colors. )

fx image

Evaluate expression for each pixel in the image.


( Consult the Fx Special Effects Image Operator for more information. )

Gamma image

Gamma-corrects an image.

Gamma image example
$im = new Imagick($input);
$im->gammaImage( 2, imagick::CHANNEL_RED );
$im->writeImage('gammaImage.jpg'); 
$im->destroy();

( The same image viewed on different devices will have perceptual differences in the way the image's intensities are represented on the screen. Specify individual gamma levels for the red, green, and blue channels, or adjust all three with the gamma parameter. Values typically range from 0.8 to 2.3.
God knows how thw channel selection is supposed to work! )

Gaussian blur image

Blurs an image.

Gaussian blur image example
$im = new Imagick($input);
$im->gaussianBlurImage( 2, 3 );
$im->writeImage('gaussianBlurImage.jpg'); 
$im->destroy();

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

Get color as string

Returns the color of the ImagickPixel object as a string.

Get the color as a string: rgb(105,134,6)

$im = new Imagick($input);
$pixel = $im->getImagePixelColor( 78, 22 );
echo '
Get the color as a string: '.($pixel->getColorAsString()); $im->destroy();

Get color count

Returns the color count associated with this color.

Not working

$im = new Imagick($input);
$pixel = $im->getImagePixelColor( 78, 22 );
echo '
Color count: '.$pixel->getColorCount(); $im->destroy();

Get color value

Retrieves the value of the color channel specified, as a floating-point number between 0 and 1.

Alpha: 1
Opacity: 0
Red value: 105
Green value: 134
Blue value: 6


$im = new Imagick($input);
$pixel = $im->getImagePixelColor( 78, 22 );
echo '
Alpha: '.$pixel->getColorValue(imagick::COLOR_ALPHA); echo '
Opacity: '.$pixel->getColorValue(imagick::COLOR_OPACITY); echo '
Red value: '.round( 255 * ($pixel->getColorValue(imagick::COLOR_RED))); echo '
Green value: '.round( 255 * ($pixel->getColorValue(imagick::COLOR_GREEN))); echo '
Blue value: '.round( 255 * ($pixel->getColorValue(imagick::COLOR_BLUE))); $im->destroy();

( )

Get colorspace

Gets the global colorspace value.

My version is to old

/*
$im = new Imagick($input);
$colorspace = $im->getColorspace();
echo "
Image colorspace = $colorspace"; */

Get compression

Gets the object compression type.

Image compression = 0

$im = new Imagick($input);
$compression = $im->getCompression();
echo "
Image compression = $compression";

( imagick::COMPRESSION_UNDEFINED 0
imagick::COMPRESSION_NO 1
imagick::COMPRESSION_BZIP 2
imagick::COMPRESSION_DXT1 3
imagick::COMPRESSION_DXT3 4
imagick::COMPRESSION_DXT5 5
imagick::COMPRESSION_FAX 6
imagick::COMPRESSION_GROUP4 7
imagick::COMPRESSION_JPEG 8
imagick::COMPRESSION_JPEG2000 9
imagick::COMPRESSION_LOSSLESSJPEG 10
imagick::COMPRESSION_LZW 11
imagick::COMPRESSION_RLE 12
imagick::COMPRESSION_ZIP 13
)