过滤器
Syntax
RESOURCE.Filter FILTER...
Returns
resources.resourceAdapter
将一个或多个image filters应用于给定的图像。
使用一个过滤器:
{{ with resources.Get "images/original.jpg" }}
{{ with .Filter images.Grayscale }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
应用两个或更多过滤器,从左到右执行:
{{ $filters := slice
images.Grayscale
(images.GaussianBlur 8)
}}
{{ with resources.Get "images/original.jpg" }}
{{ with .Filter $filters }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
您还可以使用images.Filter
函数应用图像过滤器。
示例
{{ with resources.Get "images/original.jpg" }}
{{ with .Filter images.Grayscale }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
Original

Processed

图像过滤器
使用下列任意过滤器与Filter
方法。