Skip to content

Instantly share code, notes, and snippets.

@pokehanai
Last active November 11, 2018 08:12
Show Gist options
  • Save pokehanai/32cdec7ea973daf9dd0c90ee433a6e13 to your computer and use it in GitHub Desktop.
Save pokehanai/32cdec7ea973daf9dd0c90ee433a6e13 to your computer and use it in GitHub Desktop.
image orientation correction
// 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