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

Get image border color

Returns the image border color.

Get image channel depth

Gets the depth for a particular image channel.

Red channel depth = 8

$image = new Imagick($input);
$image->readImage($input);
$channelDepth = $image->getImageChannelDepth($image::CHANNEL_RED);
echo "Red channel depth = $channelDepth";

Get image channel distortion

Compares one or more image channels of an image to a reconstructed image and returns the specified distortion metric.

Get image channel distortions

Compares one or more image channels of an image to a reconstructed image and returns the specified distortion metrics

Get image channel extrema

Gets the extrema for one or more image channels.


( Return value is an associative array with the keys "minima" and "maxima". )

Get image channel kurtosis

Get the kurtosis and skewness of a specific channel

Get image channel mean

Gets the mean and standard deviation of one or more image channels.

Image red channel mean:
Mean = 24879.5189333 Standard deviation = 19329.6731651

$im = new Imagick($input);
$mean = $im->getImageChannelMean( $im::CHANNEL_RED );
echo "Image red channel mean
"; echo "Mean = ".$mean['mean']." Standard deviation = ".$mean[standardDeviation]."
";

( Return value is an associative array with the keys "mean" and "standardDeviation". )

Get image channel range

Gets the range for one or more image channels.

Image red channel range:
Minima = 0 Maxima = 65535

$im = new Imagick($input);
$range = $im->getImageChannelRange( $im::CHANNEL_RED );
echo "Image red channel range:
"; echo "Minima = ".$range['minima']." Maxima = ".$range['maxima']."
";

Get image channel statistics

Returns statistics for each channel in the image.

echo '<pre>';
$image = new Imagick($input);
$image->readImage($input);
$channelStatistics = $image->getImageChannelStatistics();
echo "Channel statistics:<br>". print_r($channelStatistics);
echo'</pre>';

( The statistics include the channel depth, its minima and maxima, the mean, and the standard deviation.
Partial output:
Array ( [0] => Array ( [mean] => 0 [minima] => 1.7976931348623E+308 [maxima] => -1.7976931348623E+308 [standardDeviation] => 0 [depth] => 1 ) [1] => Array ( [mean] => 25222.1217723 [minima] => 0 [maxima] => 65535 [standardDeviation] => 19788.444046042 [depth] => 8 ) [2] => Array )

Get image clip mask

Returns the image clip mask.


( The clip mask is an Imagick object containing the clip mask. )

Get image color map color

Returns the color of the specified colormap index.

Get image colors

Gets the number of unique colors in the image.

Image colors = 21436

$im = new Imagick($input);
$colors = $im->getImageColors();
echo "
Image colors = $colors";

( $im = new Imagick($input); $colorspace = $im->getImageColorspace(); echo "
Image colorspace = $colorspace"; )

Get image colorspace

Gets the image colorspace.

Image colorspace = 13

$image=new Imagick();
$image->readImage($input);
$colorspace = $image->getImageColorspace();
echo "<br>Image colorspace = $colorspace";

Get image compose

Returns the composite operator associated with the image.