Sunday, August 31, 2025
HomeLanguagesPHP | Gmagick getimageextrema() Function

PHP | Gmagick getimageextrema() Function

The Gmagick::getimageextrema() function is an inbuilt function in PHP which is used to get the extrema for an image. Extrema are the points at which a maximum or minimum value of a function is observed.

Syntax:

array Gmagick::getimageextrema( void )

Parameters:This function doesn’t accept any parameters.

Return Value: This function returns an associative array containing the keys as “min” and “max”.

Exceptions: This function throws GmagickException on error.

Below given programs illustrate the Gmagick::getimageextrema() function in PHP:

Program 1 (For multiple colored image):




<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('neveropen.png');
  
// Get the extrema
$extrema = $gmagick->getimageextrema();
print("<pre>".print_r($extrema, true)."</pre>");
?>


Output:

Array
(
    [min] => 0
    [max] => 65535
)

Program 2 (For single colored image):




<?php
  
// Create a new Gmagick object
$gmagick = new Gmagick('singlecolor.png');
   
// Get the extrema
$extrema = $gmagick->getimageextrema();
print("<pre>".print_r($extrema, true)."</pre>");
?>


Output:

Array
(
    [min] => 7710
    [max] => 7710
)

Reference: https://www.php.net/manual/en/gmagick.getimageextrema.php

RELATED ARTICLES

Most Popular

Dominic
32250 POSTS0 COMMENTS
Milvus
81 POSTS0 COMMENTS
Nango Kala
6619 POSTS0 COMMENTS
Nicole Veronica
11792 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11840 POSTS0 COMMENTS
Shaida Kate Naidoo
6734 POSTS0 COMMENTS
Ted Musemwa
7014 POSTS0 COMMENTS
Thapelo Manthata
6689 POSTS0 COMMENTS
Umr Jansen
6704 POSTS0 COMMENTS