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:
parent
4b3abd2a17
commit
d45ad6e1ae
1 changed files with 13 additions and 0 deletions
13
layouts/partials/images/orientation_angle.html
Normal file
13
layouts/partials/images/orientation_angle.html
Normal 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 }}
|
Loading…
Add table
Add a link
Reference in a new issue