Wednesday, November 19, 2025
HomeLanguagesPHP | Imagick setImageGamma() Function

PHP | Imagick setImageGamma() Function

The Imagick::setImageGamma() function is an inbuilt function in PHP which is used to set the image gamma.

Syntax:

bool Imagick::setImageGamma( float $gamma )

Parameters: This function accepts a single parameter $gamma which holds the gamma for the image.

Return Value: This function returns TRUE on success.

Exceptions: This function throws ImagickException on error.

Below given programs illustrate the Imagick::setImageGamma() function in PHP:

Program 1:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Gamma
$imagick->setImageGamma(5);
  
// Display the image
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>


Output:

Program 2:




<?php
  
// Create a new imagick object
$imagick = new Imagick(
  
// Set the Gamma
$imagick->setImageGamma(15);
  
// Add a border
$imagick->borderImage('black', 2, 2);
  
// Display the image
header("Content-Type: image/png");
echo $imagick->getImageBlob();
?>


Output:

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

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32404 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6775 POSTS0 COMMENTS
Nicole Veronica
11924 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11994 POSTS0 COMMENTS
Shaida Kate Naidoo
6903 POSTS0 COMMENTS
Ted Musemwa
7159 POSTS0 COMMENTS
Thapelo Manthata
6859 POSTS0 COMMENTS
Umr Jansen
6846 POSTS0 COMMENTS