images.Mask
Syntax
images.Mask RESOURCE
Returns
images.filter
The images.Mask
filter applies a mask to an image. Black pixels in the mask make the corresponding areas of the base image transparent, while white pixels keep them opaque. Color images are converted to grayscale for masking purposes. The mask is automatically resized to match the dimensions of the base image.
Usage
Create the filter:
{{ $filter := images.Mask "images/mask.png" }}
Apply the filter using the images.Filter
function:
{{ with resources.Get "images/original.jpg" }}
{{ with . | images.Filter $filter }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
You can also apply the filter using the Filter
method on a Resource
object:
{{ with resources.Get "images/original.jpg" }}
{{ with .Filter $filter }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
Example
Mask
Original
Processed