Fork me on GitHub

fill — fill image with color or pattern


public Intervention\Image\Image fill(mixed $source, [integer $pos_x, integer $pos_y])

Fill current image with given color or another image used as tile for filling. Pass optional x, y coordinates to start at a certain point.

If a certain position is defined, the color at that point on the original image is used to perform a flood fill. If no x,y coordinates are passed, the whole picture is filled no matter what is beneath.



The fill color or image pattern. Pass a color as one of the different color formats or to fill the image with tiles an image resource in the following formats:

pos_x (optional)

Starting point on x-axis for the filling.

pos_y (optional)

Starting point on y-axis for the filling.

If a x, y coordinate is defined the filling will be flood filled based on the color at this position.

Return Values

Instance of Intervention\Image\Image


// create empty canvas
$img = Image::canvas(800, 600);

// fill image with color

// fill image with tiled image

// flood fill image with color
$img->fill('#ff00ff', 0, 0);

See also