images.Overlay
语法
images.Overlay RESOURCE X Y
返回值
images.filter
用法
将叠加图像捕获为资源
{{ $overlay := "" }}
{{ $path := "images/logo.png" }}
{{ with resources.Get $path }}
{{ $overlay = . }}
{{ else }}
{{ errorf "Unable to get resource %q" $path }}
{{ end }}
创建过滤器
{{ $filter := images.Overlay $overlay 20 20 }}
使用 images.Filter
函数应用过滤器
{{ with resources.Get "images/original.jpg" }}
{{ with . | images.Filter $filter }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
您也可以使用 Resource
对象上的 Filter
方法应用过滤器
{{ with resources.Get "images/original.jpg" }}
{{ with .Filter $filter }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}
示例
原始

已处理
