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: 8
Get image compression
Gets the current image's compression type.
Get image delay
Gets the image delay.
Get image depth
Gets the image depth.
Image depth = 8$im = new Imagick($input); $imageDepth = $im->getImageDepth(); echo "Image depth = $imageDepth";
Get image dispose
Gets the image disposal method.
Get image distortion
Compares an image to a reconstructed image and returns the specified distortion metric.
Get image extrema
Gets the extrema for the image.
Image colorspace = Array ( [min] => 0 [max] => 65535 )echo '<pre>'; $image=new Imagick(); $image->readImage($input); $imageExtrema = $image->getImageExtrema(); print_r($imageExtrema); echo '</pre>';
( Returns an associative array with the keys "min" and "max". )
Get image filename
$im = new Imagick($input); $filename = $im->getImageFilename(); echo "<br>Image filename = $filename";
Get image format
Returns the format of a particular image in a sequence.
Image format = JPEG$im = new Imagick($input); $format = $im->getImageFormat(); echo "Image format = $format<br>";
Get image gamma
Gets the image gamma.
Image gamma = 0.45454543828964$image=new Imagick(); $image->readImage($input); $imageGamma = $image->getImageGamma(); echo "
Image gamma = $imageGamma";
Get image geometry
Returns the width and height as an associative array.
$im = new imagick($input); $geometry = $im->getImageGeometry(); $sizex = $geometry['width']; $sizey = $geometry['height'];
Get image gravity
Gets the current gravity value of the image.
( Unlike getGravity(), this method returns the gravity defined for the current image sequence. )
Get image green primary
Returns the chromaticity green primary point. Returns an array with the keys "x" and "y".
Array ( [x] => 0.30000001192093 [y] => 0.60000002384186 ) Green primary = 1$im = new Imagick($input); $greenPrimary = $im->getImageGreenPrimary(); echo "Green primary = ". print_r($greenPrimary);
Get image height
Returns the image height.
The image height is 150$im = new Imagick($input); $height = $im->getImageHeight(); echo "
Image height = $height";
Get image histogram
Returns the image histogram as an array of ImagickPixel objects.
R G B A Qty3 0 0 1 : 2
3 1 0 1 : 3
$im = new Imagick(); $im->readImage($input); $histogram = $im->getImageHistogram (); echo " R G B A Qty<br>"; foreach( $histogram as $color ){ $colors = $color->getColor(); foreach( $colors as $c ){ print( "$c\t" ); } print( "\t:\t" . $color->getColorCount() . "<br>" ); }
( First couple of line only displayed. )