Skip to content

Instantly share code, notes, and snippets.

@levantAJ
Last active April 12, 2017 09:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save levantAJ/bbf2549b2b1caf1565c69f11975182c2 to your computer and use it in GitHub Desktop.
Save levantAJ/bbf2549b2b1caf1565c69f11975182c2 to your computer and use it in GitHub Desktop.
Exif Orientation from current device orientation
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