Skip to content

Instantly share code, notes, and snippets.

@steipete
Created January 29, 2013 18:43
Show Gist options
  • Save steipete/4666527 to your computer and use it in GitHub Desktop.
Save steipete/4666527 to your computer and use it in GitHub Desktop.
Exif -> UIImageOrientation
// Convert an EXIF image orientation to an iOS one.
// reference see here: http://sylvana.net/jpegcrop/exif_orientation.html
+ (UIImageOrientation) exifOrientationToiOSOrientation:(int)exifOrientation {
UIImageOrientation o = UIImageOrientationUp;
switch (exifOrientation) {
case 1: o = UIImageOrientationUp; break;
case 3: o = UIImageOrientationDown; break;
case 8: o = UIImageOrientationLeft; break;
case 6: o = UIImageOrientationRight; break;
case 2: o = UIImageOrientationUpMirrored; break;
case 4: o = UIImageOrientationDownMirrored; break;
case 5: o = UIImageOrientationLeftMirrored; break;
case 7: o = UIImageOrientationRightMirrored; break; default: break;
}
return o;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment