Skip to content

Instantly share code, notes, and snippets.

@bitcartel
Forked from erans/UIImage+Resize.m
Created March 23, 2012 05:15
Show Gist options
  • Save bitcartel/2167139 to your computer and use it in GitHub Desktop.
Save bitcartel/2167139 to your computer and use it in GitHub Desktop.
UIImage+Resize.m Fix for Rotation / Orientation on iOS 5
- (UIImage *)resizedImage:(CGSize)newSize interpolationQuality:(CGInterpolationQuality)quality {
BOOL drawTransposed;
CGAffineTransform transform = CGAffineTransformIdentity;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
// Apprently in iOS 5 the image is already correctly rotated, so we don't need to rotate it manually
drawTransposed = NO;
} else {
switch (self.imageOrientation) {
case UIImageOrientationLeft:
case UIImageOrientationLeftMirrored:
case UIImageOrientationRight:
case UIImageOrientationRightMirrored:
drawTransposed = YES;
break;
default:
drawTransposed = NO;
}
transform = [self transformForOrientation:newSize];
}
return [self resizedImage:newSize
transform:transform
drawTransposed:drawTransposed
interpolationQuality:quality];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment