PHP | Imagick levelImage() Function
The Imagick::levelImage() function is an inbuilt function in PHP which is used to adjust the levels of an image.
Syntax:
bool Imagick::levelImage( $blackPoint, $gamma,
$whitePoint, $channel = Imagick::CHANNEL_DEFAULT )
Parameters: This function accepts four parameters as mentioned above and described below:
- blackPoint: This parameter holds the black point of an image.
- gamma: This parameter holds the value of gamma.
- whitePoint: This parameter holds the white point of an image.
- channel: This parameter holds the channel constant that is valid for channel mode. Use bit-wise operator to combine more then one channel.
Return Value: This function returns TRUE on success.
Errors/Exceptions: This function throws ImagickException on error.
Below program illustrates the Imagick::levelImage() function in PHP:
Program:
<?php // Store the image into variable $imagick= // Declare new Imagick object $imagick = new \Imagick($imagick); // Use Imagick::newPseudoImage() function to create // a new image using ImageMagick pseudo-formats $imagick->newPseudoimage(700, 250, 'radial-gradient:red-blue'); // Function to set image format $imagick->setFormat('png'); // Use Imagick::getQuantum() function to // return the ImageMagick quantum range $quantum = $imagick->getQuantum(); // Use Imagick::levelImage() function $imagick->levelImage($blackPoint / 100, $gamma, $quantum * $whitePoint / 100); header("Content-Type: image/png"); // Display the image as output echo $imagick->getImageBlob(); ?> |
Output:

Reference: https://www.php.net/manual/en/imagick.levelimage.php
Recommended Posts:
- PHP | Imagick flipImage() Function
- PHP | Imagick getImageGamma() Function
- PHP | Imagick getImageColorspace() Function
- PHP | Imagick shadeImage() Function
- PHP | Imagick vignetteImage() Function
- PHP | Imagick getImageColors() Function
- PHP | Imagick opaquePaintImage() Function
- PHP | Imagick chopImage() Function
- PHP | Imagick brightnessContrastImage() Function
- PHP | Imagick getInterlaceScheme() Function
- PHP | Imagick getImageTicksPerSecond() Function
- PHP | Imagick getImageSignature() Function
- PHP | Imagick radialBlurImage() Function
- PHP | Imagick randomThresholdImage() Function
- PHP | Imagick identifyImage() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



