PHP | Gmagick getimagegamma() Function

The Gmagick::getimagegamma() function is an inbuilt function in PHP which is used to get the image gamma. The Gamma is a nonlinear operation used to encode and decode luminance or tristimulus values in images.

Syntax:

float Gmagick::getimagegamma( void )

Parameters: This function doesn’t accept any parameter.

Return Value: This function returns an float value containing the gamma.

Exceptions: This function throws GmagickException on error.

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

Program 1 (For image with multiple colors):




<?php
  
// Create a new Gmagick object
// https://media.w3wiki.net/wp-content/uploads/w3wiki-13.png
$gmagick = new Gmagick('w3wiki.png');
  
// Get the gamma
$gamma = $gmagick->getimagegamma();
echo $gamma;
?>


Output:

0.45454999804497

Program 2 (For image with single color):




<?php
  
// Create a new Gmagick object
// https://media.w3wiki.net/wp-content/uploads/20200106200505/singlecolor.png
$gmagick = new Gmagick('singlecolor.png');
  
// Get the gamma
$gamma = $gmagick->getimagegamma();
echo $gamma;
?>


Output:

0

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


Contact Us