Add orientation-angle partial from old website theme
This commit is contained in:
parent
140a6d6401
commit
5cbb3a4fe8
1 changed files with 30 additions and 0 deletions
30
layouts/partials/image-utilities/orientation-angle.html
Normal file
30
layouts/partials/image-utilities/orientation-angle.html
Normal file
|
@ -0,0 +1,30 @@
|
|||
{{ $orientation := 0 }}
|
||||
|
||||
{{ with .Params.orientation }}
|
||||
{{ if strings.Contains . "horizontal" }}
|
||||
{{ $orientation = 0 }}
|
||||
{{ else if strings.Contains . "rotate180" }}
|
||||
{{ $orientation = 180 }}
|
||||
{{ else if strings.Contains . "rotate90" }}
|
||||
{{ $orientation = 90 }}
|
||||
{{ else if strings.Contains . "rotate270" }}
|
||||
{{ $orientation = 270 }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ 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 }}
|
||||
{{ end }}
|
||||
|
||||
{{ return $orientation }}
|
Loading…
Add table
Add a link
Reference in a new issue