mirror of
https://github.com/gohugoio/hugoDocs.git
synced 2025-09-09 07:55:17 -04:00
Improve description of masking with non-transparent images
This commit is contained in:
parent
41c8feb645
commit
4171c0eb7d
@ -18,11 +18,17 @@ toc: true
|
||||
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.
|
||||
|
||||
{{% note %}}
|
||||
Of the formats supported by Hugo's imaging pipelie, only PNG and WebP have an alpha channel to support transparency. If your source image uses a different format, convert it to either PNG or WebP before applying the mask as shown in the example below.
|
||||
|
||||
Applying an image mask to a non-transparent image format such as JPEG will result in masked areas appearing white instead of transparent.
|
||||
Of the formats supported by Hugo's imaging pipelie, only PNG and WebP have an alpha channel to support transparency. If your source image has a different format and you require transparent masked areas, convert it to either PNG or WebP as shown in the example below.
|
||||
{{% /note %}}
|
||||
|
||||
When applying a mask to a non-transparent image format such as JPEG, the masked areas will be filled with the color specified by the `bgColor` parameter in your [site configuration]. You can override that color with a `Process` image filter:
|
||||
|
||||
```go-html-template
|
||||
{{ $filter := images.Process "#00ff00" }}
|
||||
```
|
||||
|
||||
[site configuration]: /content-management/image-processing/#imaging-configuration
|
||||
|
||||
## Usage
|
||||
|
||||
Create a slice of filters, one for WebP conversion and the other for mask application:
|
||||
|
Loading…
x
Reference in New Issue
Block a user