Last Updated: February 25, 2016
·
1.561K
· hsadan

Saving Photos the Right Way

when doing writeImageToSavedPhotosAlbum you can't just simply take UIImageOrientation as kCGImagePropertyOrientation, and UIImageOrientation can be confusing as to what exactly is "Up"

The following snippet will help with that:

- (int) metadataOrientationForUIImageOrientation:(UIImageOrientation)orientation
{
    switch (orientation) {
        case UIImageOrientationUp: // home button on right
            return 1;
        case UIImageOrientationRight: // bottom (portrait)
            return 6;
        case UIImageOrientationDown: // left
            return 3;
        case UIImageOrientationLeft: // top
            return 8;
        default:
            return 1;
    }
}

sources:
http://stackoverflow.com/a/6699649
http://d.hatena.ne.jp/mmtootmm/20120809/1344494972