HomeLanguagesPHP | imagegammacorrect() function

PHP | imagegammacorrect() function

The imagegammacorrect() function is an inbuilt function in PHP which is used to apply gamma correction to the given image given an input and an output gamma.

Syntax:

bool imagegammacorrect( resource $image, float $inputgamma, float $outputgamma )

Parameters:This function accepts three parameters as mentioned above and described below:

  • $image: It specifies the image to be worked upon.
  • $inputgamma: It specifies the input gamma.
  • $outputgamma: It specifies the output gamma.

Return Value: This function returns TRUE on success or FALSE on failure.

Exceptions: This function throws Exception on error.

Below given programs illustrate the imagegammacorrect() function in PHP:
Program 1:




<?php
// Create an image
  
// Change the image gamma
imagegammacorrect($im, 3, 1.3);
  
// Output to browser
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>


Output:

Program 2:




<?php
// Create an empty image
$im = imagecreatetruecolor(800, 250);
  
// Set the background to be light blue
imagefilledrectangle($im, 0, 0, 800, 250, imagecolorallocate($im, 0, 0, 180));
  
// Add text using a font from local
imagefttext($im, 80, 0, 50, 130, imagecolorallocate($im, 0, 150, 0), './Pacifico.ttf', 'neveropen');
  
// Change the image gamma
imagegammacorrect($im, 3, 1.3);
  
// Output to browser
header('Content-Type: image/png');
imagepng($im);
imagedestroy($im);
?>


Output:

Reference: https://www.php.net/manual/en/function.imagegammacorrect.php

RELATED ARTICLES

Most Popular

Dominic
32688 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7057 POSTS0 COMMENTS
Nicole Veronica
12198 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12293 POSTS0 COMMENTS
Shaida Kate Naidoo
7182 POSTS0 COMMENTS
Ted Musemwa
7447 POSTS0 COMMENTS
Thapelo Manthata
7160 POSTS0 COMMENTS
Umr Jansen
7150 POSTS0 COMMENTS