Open In App

PHP | Imagick getImageHistogram() Function

Last Updated : 20 Nov, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
The Imagick::getImageHistogram() function is an inbuilt function in PHP which is used to get the image histogram. Syntax:
array Imagick::getImageHistogram( void )
Parameters: This function does not accept any parameter. Return Value: This function returns an array of ImagickPixel objects containing histogram of image. Exceptions: This function throws ImagickException on error. Below program illustrates the Imagick::getImageHistogram() function in PHP: Program 1: php
<?php

// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png');

// Get the Histogram
$histogram = $imagick->getImageHistogram();

print("<pre>".print_r($histogram, true)."</pre>");
?>
Output:
Returns an array with 2955 Imagick objects as members.
Program 2: php
<?php

// Create a new imagick object
$imagick = new Imagick(
'https://media.geeksforgeeks.org/wp-content/uploads/20190918234528/colorize1.png');

// Get the Histogram
$histogram = $imagick->getImageHistogram();

print("<pre>".print_r($histogram, true)."</pre>");
?>
Output:
Returns an array with 1725 Imagick objects as members.
Reference: https://www.php.net/manual/en/imagick.getimagehistogram.php

Next Article

Similar Reads