PHP | Imagick paintFloodFillImage() Function

The paintFloodFillImage() function is an inbuilt function in PHP which is used to change the color value of any pixel that matches to the target and is an immediate neighbor.


bool Imagick::paintFloodFillImage( $fill, $fuzz, $bordercolor, 
                                   $x, $y, $channel = Imagick::CHANNEL_DEFAULT )

Note: This function is being replaced by Imagick::floodFillPaintImage() function.

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

  • $fill: It holds the ImagickPixel object or a string value to fill the color.
  • $fuzz: It defines the amount of fuzz.
  • $bordercolor: It holds the ImagickPixel object or a string value of the border pixel color.
  • $x: It contains the start position of x-axis of the floodfill.
  • $y: It contains the start position of y-axis of the floodfill.
  • $invert: It contains the Boolean value either TRUE or FALSE. TRUE paints any pixel that does not match the target color.
  • $channel: It contains the channel constants. More than one channel constants can be combined using bitwise operators.

Return Value: This function returns TRUE on success.

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






// Creating an imagick object
$img = new Imagick(
// Use Imagick::paintFloodFillImage() function to change the 
// color value of the target color
$img->floodFillPaintImage('cyan', 1, 'white', 1, 1, false); 
header("Content-Type: image/png"); 
// Display the output image 
echo $img->getImageBlob(); 




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 or mail your article to 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 to report any issue with the above content.