Add images/orientation_angle partial that returns the angle (in degress) of the orientation from an image's Exif info

This commit is contained in:
Eryn Wells 2022-10-25 17:55:47 -04:00
parent 4b3abd2a17
commit d45ad6e1ae

View file

@ -0,0 +1,13 @@
{{ $orientation := .Exif.Tags.Orientation }}
{{/* EXIF orientation is specified as an integer corresponding to a 90º rotation. */}}
{{ $angle := 0 }}
{{ if in (slice 1 2) $orientation }}
{{ $orientation = 0 }}
{{ else if in (slice 3 4) $orientation }}
{{ $orientation = 180 }}
{{ else if in (slice 5 6) $orientation }}
{{ $orientation = 90 }}
{{ else if in (slice 7 8) $orientation }}
{{ $orientation = 270 }}
{{ end }}
{{ return $orientation }}