images.Filter
Apply one or more image filters to the given image.
To apply a single filter:
{{ with resources.Get "images/original.jpg" }}
{{ with images.Filter images.Grayscale . }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
To apply two or more filters, executing from left to right:
{{ $filters := slice
images.Grayscale
(images.GaussianBlur 8)
}}
{{ with resources.Get "images/original.jpg" }}
{{ with images.Filter $filters . }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
You can also apply image filters using the Filter
method on a Resource
object.
Example​
{{ with resources.Get "images/original.jpg" }}
{{ with images.Filter images.Grayscale . }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
Image filters​
Use any of these filters with the images.Filter
function, or with the Filter
method on a Resource
object.