Friday, October 3, 2025
HomeLanguagesPHP | Imagick paintFloodFillImage() Function

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.

Syntax:

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:

Program:




<?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(); 
?>


Output:
paintFloodFillImage()

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

RELATED ARTICLES

Most Popular

Dominic
32331 POSTS0 COMMENTS
Milvus
85 POSTS0 COMMENTS
Nango Kala
6703 POSTS0 COMMENTS
Nicole Veronica
11867 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11929 POSTS0 COMMENTS
Shaida Kate Naidoo
6818 POSTS0 COMMENTS
Ted Musemwa
7080 POSTS0 COMMENTS
Thapelo Manthata
6775 POSTS0 COMMENTS
Umr Jansen
6776 POSTS0 COMMENTS