PHP | Imagick clutImage() Function

The Imagick::clutImage() function is an inbuilt function in PHP which is used to replace the colors in the image. The second parameter of this function replaces the color in a specific channel.

Syntax:

bool Imagick::clutImage( $lookup_table, $channel = Imagick::CHANNEL_DEFAULT )

Parameters: This function accpets two parameters as mentioned above and described below:

  • $lookup_table: This parameter containing Imagick object for color lookup table.
  • $channel: It is the channel constants which provides any channel that is valid for your channel mode. The default value of $channel is Imagick::CHANNEL_DEFAULT.

Return Value: This function returns True on success or false on failure.

Below program illustrates the Imagick::clutImage() function in PHP:



Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Declare an Imagick object
$image = new Imagick(
  
$clut = new Imagick();
  
// Imagick object choosen green color from color lookup table
$clut->newImage(1, 1, new ImagickPixel('green'));
  
// No channel is applied hence default channel is used
$image->clutImage($clut);
  
header("Content-Type: image/jpg");
   
// Display the output image
echo $image->getImageBlob();
?>

chevron_right


Output:

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

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

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.