Javatpoint Logo
Javatpoint Logo

Imagick floodFillPaintImage() Function

Any pixel that matches the target and is an immediate neighbor has its color value changed. This function is a replacement for Imagick::paintFloodFillImage, which has been deprecated (). If Imagick has been compiled against ImageMagick version 6.3.8 or newer, this approach is accessible.

Parameters

Fill

A string containing the fill color or an ImagickPixel object

fuzz

The level of fuzziness. Set fuzz to ten and the colors red and green at intensities of 100 and 102 are now regarded as the same color.

target

ImagickPixel object or a string specifying the color to be painted

x

X The flood fills starting point

y

The floodfill's starting location in Y.

invert

If true, each pixel that does not match the desired color will be painted.

channel

Provide any valid channel constant for your channel mode. Combine channel constants with bitwise operators to apply to multiple channels. Imagick::CHANNEL DEFAULT is the default. This list of channel constants may be found here.

Return Type

The return type of the flood fill paint image is of the Boolean type which means the returning value of this function either be true or false depending upon the success or failure of the operation. the return type of the flood fill paid image is true when the flood fill operation is successful to the targeted pixel or the set of pixels which is passed as a parameter to this function and on the other side, the return type of this function will be changed to false when the flood fill operation on the specified target pixel is not successful.

Code:

Output:

Imagick floodFillPaintImage() Function

In the above-written code first of all we have created an Imagick object and after the creation of that Imagick object with the use of that Imagick object, we have created three images of red, green, and blue colors after the creation of these three images we have appended all the three images into one single image and has stored that image. Once we have our initial image ready, the next step is to change the color of a particular set of targeted pixels so for changing the color of the specific target set of pixels we have used the flood fill paint image function in PHP and we have to change the targeted color to the black color and after the successful transformation of the color of the specified set of pixels, the resultant image is stored in another image in PNG format.

Another example:

In this example, we are discussing a specific case in which we can reduce the noise created by this function. First of all in this example, we have created an Imagick object and we have opened our image on which we have to perform the operations the first operation is to remove the background with transparent color so when we are first time using the flood fill paint image function majority of the part is getting removed but some background colors are still present in the image so in order to reduce this error rate we have again called the flood fill paint image just with some different parameter values so with the help of this different parameter values we were able to totally remove the background color of the specified image.

Therefore, in this article, we have seen how we can use the Imagick flood fill paint image function in PHP to fill our desired color to our specified target set of pixels.







Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA