Monday, January 26, 2026
HomeLanguagesPHP | Imagick getImageChannelExtrema() Function

PHP | Imagick getImageChannelExtrema() Function

The Imagick::getImageChannelExtrema() function is an inbuilt function in PHP which is used to get the extrema for one or more image channels. Extrema are the points at which a maximum or minimum value of a function is observed. It returns an associative array with the keys “minima” and “maxima”.

Syntax:

array Imagick::getImageChannelExtrema(int $channel)

Parameters: This function accepts single parameter $channel which specifies the channel constant that is valid for your channel mode. Use bitwise operator to combine channeltype constants.

Exceptions: This function throws ImagickException on error.

Return Value: This function returns TRUE on success.

Below programs illustrate the Imagick::getImageChannelExtrema() function in PHP:

Program 1:




<?php
  
// Create new imagick object
$imagick = new Imagick(
  
// Get the extrema with CHANNEL constant as 0
// which corresponds to imagick::CHANNEL_UNDEFINED
$extrema = $imagick->getImageChannelExtrema(0);
print_r($extrema);
?>


Output:

Array ( [minima] => 0 [maxima] => -9223372036854775808 )

Program 2:




<?php
  
// Create new imagick object
$imagick = new Imagick(
  
// Get the extrema with CHANNEL constant as 6
// which corresponds to imagick::CHANNEL_BLUE
$extrema = $imagick->getImageChannelExtrema(6);
print_r($extrema);
?>


Output:

Array ( [minima] => 5654 [maxima] => 65535 )

Reference: https://www.php.net/manual/en/imagick.getimagechannelextrema.php

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32475 POSTS0 COMMENTS
Milvus
122 POSTS0 COMMENTS
Nango Kala
6847 POSTS0 COMMENTS
Nicole Veronica
11978 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12065 POSTS0 COMMENTS
Shaida Kate Naidoo
6986 POSTS0 COMMENTS
Ted Musemwa
7221 POSTS0 COMMENTS
Thapelo Manthata
6934 POSTS0 COMMENTS
Umr Jansen
6912 POSTS0 COMMENTS