PHP | Gmagick levelimage() Function
The Gmagick::levelimage() function is an inbuilt function in PHP which is used to adjust the levels of an image by scaling the colors falling between specified white and black points to the full available quantum range.
Syntax:
mixed Gmagick::levelimage( float $blackPoint, float $gamma,
float $whitePoint, int $channel = Gmagick::CHANNEL_DEFAULT )
Parameters: This function accept four parameters as mentioned above and described below:
- $blackPoint: It specifies the image black point.
- $gamma: It specifies the image gamma.
- $whitePoint: It specifies the image white point.
- $channel (Optional): It specifies any channel constant that is valid for the channel mode.
Return Value: This function returns TRUE on success.
Exceptions: This function throws GmagickException on error.
Below given programs illustrate the Gmagick::levelimage() function in PHP:
Used Image:
Program 1 (Level an image):
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$gmagick ->levelimage(300000, 8, 10);
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Program 2 (Level an drawing):
<?php
$gmagick = new Gmagick( 'geeksforgeeks.png' );
$draw = new GmagickDraw();
$draw ->setFillColor( 'white' );
$draw ->rectangle(0, 0, 800, 400);
$draw ->setFillColor( 'red' );
$draw ->setfontsize(50);
$draw ->annotate(30, 100, 'GeeksforGeeks' );
$gmagick ->drawImage( $draw );
$gmagick ->levelimage(0, 34, 30);
header( "Content-Type: image/png" );
echo $gmagick ->getImageBlob();
?>
|
Output:
Reference: https://www.php.net/manual/en/gmagick.levelimage.php
Last Updated :
21 Jan, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...