Friday, March 13, 2026
HomeLanguagesPHP | Imagick getImageHistogram() Function

PHP | Imagick getImageHistogram() Function

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
  
// Create a new imagick object
$imagick = new Imagick(
  
// 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
  
// Create a new imagick object
$imagick = new Imagick(
  
// 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

RELATED ARTICLES

Most Popular

Dominic
32506 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
6882 POSTS0 COMMENTS
Nicole Veronica
12005 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12099 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7255 POSTS0 COMMENTS
Thapelo Manthata
6967 POSTS0 COMMENTS
Umr Jansen
6956 POSTS0 COMMENTS