Forked from NikhilManapure/NormalizingOrientation.swift
Created
January 23, 2019 12:56
-
-
Save Ilesh/7a98581f8287911621270321c4102707 to your computer and use it in GitHub Desktop.
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