Last active
November 11, 2018 08:12
-
-
Save pokehanai/32cdec7ea973daf9dd0c90ee433a6e13 to your computer and use it in GitHub Desktop.
image orientation correction
This file contains hidden or 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
// simple but not performance wise | |
- (UIImage *)normalizeImageOrientation:(NSString *)path { | |
UIImage *image = [UIImage imageWithContentsOfFile:path]; | |
if (image.imageOrientation != UIImageOrientationUp) { | |
CGSize size = image.size; | |
UIGraphicsBeginImageContext(size); | |
[image drawInRect:CGRectMake(0, 0, size.width, size.height)]; | |
image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
} | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment