Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Orientation issue on iOS5 #33

Closed
polyclick opened this Issue · 2 comments

3 participants

@polyclick

Hi, I'm using your component for an iOS5 project and stumbled upon some orientation problems. Some images appeared to be upside down.

I saw in the commit log that you removed your orientation fix, probably because it wasn't working 100%. But I think I found the fix:

In ELCImagePickerController.m change:

[workingDictionary setObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullScreenImage]] forKey:@"UIImagePickerControllerOriginalImage"];

with:

// Retrieve the image orientation from the ALAsset
UIImageOrientation orientation = UIImageOrientationUp;
NSNumber* orientationValue = [asset valueForProperty:@"ALAssetPropertyOrientation"];
if(orientationValue != nil) orientation = [orientationValue intValue];

[workingDictionary setObject:[UIImage imageWithCGImage:[[asset defaultRepresentation] fullResolutionImage] scale:1.0 orientation:orientation] forKey:@"UIImagePickerControllerOriginalImage"];
@jvanmetre

The [UIImage imageWithCGImage:scale:orientation] method appears to want UIImageOrientationUp to be passed in for the orientation, to return an image that is properly rotated. Some images may still be incorrectly rotated, but that would be more of an issue with the metadata on the image, than passing in a particular orientation value. This change was implemented in: 1f7e4e4

@jvanmetre jvanmetre closed this
@jackyhwb

fullScreenImage:
"In iOS 5 and later, this method returns a fully cropped, rotated, and adjusted image—exactly as a user would see in Photos or in the image picker."
https://developer.apple.com/library/ios/documentation/AssetsLibrary/Reference/ALAssetRepresentation_Class/Reference/Reference.html#//apple_ref/occ/instm/ALAssetRepresentation/fullScreenImage

    CGImageRef imgRef = [assetRep fullScreenImage];
    UIImage *img = [UIImage imageWithCGImage:imgRef
                                       scale:1.0f
                                orientation:UIImageOrientationUp ];

or use fullResolutionImage method

    CGImageRef imgRef = [assetRep  fullResolutionImage];
    UIImage *img = [UIImage imageWithCGImage:imgRef
                                       scale:1.0f
                                orientation:(UIImageOrientation)assetRep.orientation ];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.