Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Ilesh/7a98581f8287911621270321c4102707 to your computer and use it in GitHub Desktop.
Save Ilesh/7a98581f8287911621270321c4102707 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