Filter

對給定的圖像應用一個或多個 圖像濾鏡

應用單個濾鏡:

{{ 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 方法:

list-pages-in-section path=/docs/functions/images filter=functions_images_no_filters filterType=exclude