Last active
April 12, 2017 09:48
-
-
Save levantAJ/bbf2549b2b1caf1565c69f11975182c2 to your computer and use it in GitHub Desktop.
Exif Orientation from current device orientation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var exifOrientation: Int { | |
let exifOrientation: DeviceOrientation | |
enum DeviceOrientation: Int { | |
case top0ColLeft = 1 | |
case top0ColRight = 2 | |
case bottom0ColRight = 3 | |
case bottom0ColLeft = 4 | |
case left0ColTop = 5 | |
case right0ColTop = 6 | |
case right0ColBottom = 7 | |
case left0ColBottom = 8 | |
} | |
switch UIDevice.current.orientation { | |
case .portraitUpsideDown: | |
exifOrientation = .left0ColBottom | |
case .landscapeLeft: | |
if isUsingFrontFacingCamera == true { | |
exifOrientation = .bottom0ColRight | |
} else { | |
exifOrientation = .top0ColLeft | |
} | |
case .landscapeRight: | |
if isUsingFrontFacingCamera == true { | |
exifOrientation = .top0ColLeft | |
} else { | |
exifOrientation = .bottom0ColRight | |
} | |
default: | |
exifOrientation = .right0ColTop | |
} | |
return exifOrientation.rawValue | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment