From d45ad6e1ae3681f4d429e21b28d82a7b659a2b30 Mon Sep 17 00:00:00 2001 From: Eryn Wells Date: Tue, 25 Oct 2022 17:55:47 -0400 Subject: [PATCH] Add images/orientation_angle partial that returns the angle (in degress) of the orientation from an image's Exif info --- layouts/partials/images/orientation_angle.html | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 layouts/partials/images/orientation_angle.html diff --git a/layouts/partials/images/orientation_angle.html b/layouts/partials/images/orientation_angle.html new file mode 100644 index 0000000..480cfd7 --- /dev/null +++ b/layouts/partials/images/orientation_angle.html @@ -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 }}