images.Opacity
Returns an image filter that changes the opacity of an image.
- Syntax
- images.Opacity OPACITY
- Returns
- images.filter
Usage
The images.Opacity function returns an image filter that changes the opacity of an image.
The filter is most useful when the target format supports transparency, such as AVIF, PNG, or WebP. If the image has a different format, combine this filter with an images.Process filter that converts the image to one of these formats.
Arguments
OPACITY- (
float) The opacity, which must be in the range[0, 1]. A value of0produces a transparent image, a value of0.5produces a semi-transparent image, and a value of1produces an opaque image.
Examples
{{ $filter := images.Opacity 0.65 }}Applying the filter with the images.Filter function:
{{ with resources.Get "images/original.jpg" }}
{{ with . | images.Filter $filter }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}Applying the filter with 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 }}This is the original image:

This is the processed image:

Converting the image to PNG to support transparency:
{{ with resources.Get "images/original.jpg" }}
{{ $filters := slice
(images.Opacity 0.65)
(images.Process "png")
}}
{{ with . | images.Filter $filters }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}Last updated:
November 17, 2026
:
content: Apply style guide to images functions (e302e964f)
Improve this page