PHP | Imagick contrastImage() Function

The Imagick::contrastImage() function is an inbuilt function in PHP which is used to change the contrast of the image. This function enhances the intensity differences between the lighter and darker elements of the image.

Syntax:

bool Imagick::contrastImage(bool $sharpen)

Parameters: This function accepts a single parameter $sharpen which decides whether to increase or decrease the contrast.



Return Value: This function returns True on success.

Errors/Exceptions: This function throws ImagickException on error.

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

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create new Imagick object
$imagick = new Imagick(
  
// Apply the contrastImage() function
$imagick->contrastImage(false);
  
header("Content-Type: image/png");
  
// Display the output image
echo $imagick->getImageBlob();
?>

chevron_right


Output:

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create new Imagick object
$imagick = new Imagick(
  
// Apply the contrastImage() function
$imagick->contrastImage(true);
  
header("Content-Type: image/png");
  
// Display the output image
echo $imagick->getImageBlob();
?>

chevron_right


Output:

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



My Personal Notes arrow_drop_up

I love Open Source Culture have contributed to phpMyAdmin, LibreOffice, Ant-Design and Web is my passion

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.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.