Image::mask
Apply alpha masking to the current image
2.8M Downloads / Month
Open Source MIT License
2.8M Downloads / Month
Open Source MIT License
public Intervention\Image\Image mask(mixed $source, [bool $mask_with_alpha])
Apply a given image source as alpha mask to the current image to change current opacity. Mask will be resized to the current image size. By default a greyscale version of the mask is converted to alpha values, but you can set mask_with_alpha to apply the actual alpha channel. Any transparency values of the current image will be maintained.
The image source that will be applied as alpha mask. The method can handle the following types of input:
allow_url_fopen
must be enabled).Intervention\Image\Image
instanceSymfony\Component\HttpFoundation\File\UploadedFile
)Set this to true
to apply the actual alpha channel as mask to the current image instead of the color values. Default: false
Instance of Intervention\Image\Image
// create new Intervention Image
$img = Image::make('public/foo.jpg');
// Apply another image as alpha mask on image
$img->mask('public/mask.png');
// Apply a second image with alpha channel masking
$img->mask('public/alpha.png', true);