PHP | Imagick colorFloodfillImage() Function

The Imagick::colorFloodfillImage() function is an inbuilt function in PHP which is used to change the color value of any pixel that matches the target.

Syntax:

bool Imagick::colorFloodfillImage( $color, $fuzz, $bordercolor, $x, $y )

Parameters: This function accepts five parameters as mentioned above and described below:

  • color: This parameter holds the ImagickPixel object containing the filled color name in string format.
  • fuzz: This parameter holds the amount of fuzz.
  • bordercolor: This parameter holds the ImagickPixel object containing the filled border color name in string format.
  • x: It holds the x-axis start position of the floodfill.
  • y: It holds the y-axis start position of the floodfill.

Return Value: This function returns TRUE on success.

Errors/Exceptions: This function throws ImagickException on error.

Program:

filter_none

edit
close

play_arrow

link
brightness_4
code

<?php
  
// Create an Imagick object
$image = new Imagick(
  
// Use colorFloodfillImage() function to change
// the color value of any pixel
$image->colorFloodfillImage( "red", 0.2, "white", 1, 1);
  
header("Content-Type: image/jpg");
   
// Display the output
echo $image->getImageBlob();
?>

chevron_right


Output:

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



My Personal Notes arrow_drop_up

Im a final year MCA student at Panjab University, Chandigarh, one of the most prestigious university of India I am skilled in various aspects related to Web Development and AI I have worked as a freelancer at upwork and thus have knowledge on various aspects related to NLP, image processing and web

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.