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

Get image index

Returns the index of the current active image within the Imagick object.


( This method has been deprecated. See getIteratorIndex(). )

Get image interlace scheme

Gets the image interlace scheme.

The image interlace scheme is 1

$im = new Imagick($input);
$interlace = $im->getImageInterlaceScheme();

Get image interpolate method

Returns the interpolation method for the specified image.

Image interpolate method = 0

$im = new Imagick();
$im->readImage($input);
$interpolateMethod = $im->getImageInterpolateMethod();
echo "Image interpolate method = $interpolateMethod"

( The method is one of the INTERPOLATE_* constants. )

Get image iterations

Gets the image iterations.

Get image length

Returns the image length in bytes.

The image width is 16345

$im = new Imagick($input);
$width = $im->getImageLength();
echo "The image width is ".$width;

( What use is it in bytes! )

Get image magick license

Returns a string containing the ImageMagick license

Get image matte

Returns TRUE if the image has a matte channel otherwise false.

Get image matte color

Returns the image matte color.

Get image orientation

Gets the image orientation.


( The return value is one of the orientation constants. )

Get image page

Returns the page geometry associated with the image

echo '<pre>';
$im = new Imagick();
$im->readImage($input);
$imagePage = $im->getImagePage();
echo "Image page = ".print_r($imagePage);
echo '</pre>';

( An array with the keys "width", "height", "x", and "y".

Array ( [width] => 213 [height] => 160 [x] => 0 [y] => 0 ) Image page = 1 )

Get image pixel color

Returns the color of the specified pixel.

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 image profile

Returns the named image profile.

Get image profiles

Returns all associated profiles that match the pattern.


( If TRUE is passed as second parameter only the profile names are returned. )

Get image properties

Returns all associated properties that match the pattern.

Output below

$image = $input; 
$im = new Imagick();
$im->pingImage( $image );
$info = $im->getImageProperties();
echo "<pre>";
print_r($info);
echo "</pre>";

( If TRUE is passed as second parameter only the property names are returned.
True is default.
Array
(
[create-date] => 2012-06-13T17:43:47+00:00
[jpeg:colorspace] => 2
[jpeg:sampling-factor] => 2x2,1x1,1x1
[modify-date] => 2012-06-13T17:43:47+00:00
)
)