images.AutoOrient
Returns an image filter that rotates and flips an image as needed per its Exif orientation tag.
Syntax
images.AutoOrient
Returns
images.filter
Usage
Create the filter:
{{ $filter := images.AutoOrient }}使用 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 }}
{{__hugo_ctx/}}
> [!note]
> When using with other filters, specify `images.AutoOrient` first.
```go-html-template
{{ $filters := slice
images.AutoOrient
(images.Process "resize 200x")
}}
{{ with resources.Get "images/original.jpg" }}
{{ with images.Filter $filters . }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ end }}
{{ end }}Example
Original
Processed