Created
June 22, 2017 09:50
Code for making image's orientation as .up
This file contains 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
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