Skip to content
Related Articles
Open in App
Not now

Related Articles

PHP | Imagick matteFloodfillImage() Function

Improve Article
Save Article
  • Last Updated : 10 Jun, 2022
Improve Article
Save Article

The Imagick::matteFloodfillImage() function is an inbuilt function in PHP which is used to change the transparency value of a color. This function changes the transparency value of any pixel that matches the target and is an immediate neighbor. 


bool Imagick::matteFloodfillImage(float $alpha, float $fuzz, 
                                   mixed $bordercolor, int $x, int $y)

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

  • $alpha: This parameter holds the level of transparency, 1 is fully opaque and 0 is fully transparent.
  • $alpha: This parameter holds acceptable tolerance to consider two colors as same.
  • $bordercolor: This parameter holds the ImagickPixel object or string representing the border color.
  • $x: This parameter holds the starting x coordinate of the operation.
  • $y: This parameter holds the starting y coordinate of the operation.

Return Value: This function returns TRUE on success. 

Errors/Exceptions: This function throws ImagickException on error. 

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



// Create a new Imagick object
$imagick = new Imagick(
// Applying the matteFloodfillImage() function
$imagick->matteFloodfillImage(0.5, 0, 'red', 0, 0);
header("Content-Type: image/jpg");
// Display the output image
echo $imagick->getImageBlob();




My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!