2023-10-12 11:04:19 -07:00
|
|
|
{{ $orientation := 0 }}
|
|
|
|
|
2023-12-18 11:22:14 -08:00
|
|
|
{{ with .Params.orientation }}
|
|
|
|
{{ if strings.Contains . "horizontal" }}
|
2023-10-12 11:04:19 -07:00
|
|
|
{{ $orientation = 0 }}
|
2023-12-18 11:22:14 -08:00
|
|
|
{{ else if strings.Contains . "rotate180" }}
|
2023-10-12 11:04:19 -07:00
|
|
|
{{ $orientation = 180 }}
|
2023-12-18 11:22:14 -08:00
|
|
|
{{ else if strings.Contains . "rotate90" }}
|
2023-10-12 11:04:19 -07:00
|
|
|
{{ $orientation = 90 }}
|
2023-12-18 11:22:14 -08:00
|
|
|
{{ else if strings.Contains . "rotate270" }}
|
2023-10-12 11:04:19 -07:00
|
|
|
{{ $orientation = 270 }}
|
|
|
|
{{ end }}
|
|
|
|
{{ else }}
|
2023-12-18 11:22:14 -08:00
|
|
|
{{ with (int .Exif.Tags.Orientation) }}
|
|
|
|
{{/* EXIF orientation is specified as an integer corresponding to a 90º rotation. */}}
|
|
|
|
{{ if in (slice 1 2) . }}
|
|
|
|
{{ $orientation = 0 }}
|
|
|
|
{{ else if in (slice 3 4) . }}
|
|
|
|
{{ $orientation = 180 }}
|
|
|
|
{{ else if in (slice 5 6) . }}
|
|
|
|
{{ $orientation = 90 }}
|
|
|
|
{{ else if in (slice 7 8) . }}
|
|
|
|
{{ $orientation = 270 }}
|
|
|
|
{{ end }}
|
|
|
|
{{ else }}
|
|
|
|
{{ warnf "Image missing orientation: %s" . }}
|
|
|
|
{{ end }}
|
2022-10-25 17:55:47 -04:00
|
|
|
{{ end }}
|
2023-10-12 11:04:19 -07:00
|
|
|
|
2022-10-25 17:55:47 -04:00
|
|
|
{{ return $orientation }}
|