Skip to content

Instantly share code, notes, and snippets.

@NikhilManapure
Created June 22, 2017 09:50
Show Gist options
  • Save NikhilManapure/42bf67cdc568058938c7ac38d84c4144 to your computer and use it in GitHub Desktop.
Save NikhilManapure/42bf67cdc568058938c7ac38d84c4144 to your computer and use it in GitHub Desktop.
Code for making image's orientation as .up
func imageByNormalizingOrientation() -> UIImage {
if imageOrientation == .up {
return self
}
UIGraphicsBeginImageContextWithOptions(size, false, scale)
draw(in: CGRect(origin: CGPoint.zero, size: size))
let normalizedImage: UIImage? = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return normalizedImage!
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment