-
-
Save NghiaTranUIT/f657e1cd6d3709d420de to your computer and use it in GitHub Desktop.
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
@interface UIImage (Orientation) | |
- (UIImage*)imageByNormalizingOrientation; | |
@end | |
@implementation UIImage (Orientation) | |
- (UIImage*)imageByNormalizingOrientation { | |
if (self.imageOrientation == UIImageOrientationUp) | |
return self; | |
CGSize size = self.size; | |
UIGraphicsBeginImageContextWithOptions(size, NO, self.scale); | |
[self drawInRect:(CGRect){{0, 0}, size}]; | |
UIImage* normalizedImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return normalizedImage; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment