Write a warning if an image doesn't have an orientation
Default to 0º orientation.
This commit is contained in:
		
							parent
							
								
									ff2dbdb1fd
								
							
						
					
					
						commit
						c56f91da2c
					
				
					 1 changed files with 16 additions and 11 deletions
				
			
		| 
						 | 
				
			
			@ -1,13 +1,18 @@
 | 
			
		|||
{{ $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 }}
 | 
			
		||||
{{ $orientation := 0 }}
 | 
			
		||||
 | 
			
		||||
{{ 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 }}
 | 
			
		||||
 | 
			
		||||
{{ return $orientation }}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue