iPhoneアプリ開発を始めたばかりです。ALAsset クラスを使用してフォト アルバムから写真を取得し、その写真をサーバーにアップロードしようとしています。ただし、ポートレート モードで撮影された写真は左に 90 度回転されますが、横向きの写真は正しくアップロードされます。私は何を間違っていますか?NSLog では、方向が 3 であることがわかりますが、それでも写真は左に 90 度回転しています。どんな助けでも大歓迎です。
これが私のコードのスニペットです:
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *myasset)
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
imagePath = [[documentsDirectory stringByAppendingPathComponent:@"latest_photo.jpg"] copy];
NSLog(@"imagePath = %@", imagePath);
ALAssetRepresentation *rep = [myasset defaultRepresentation];
ALAssetOrientation orientation = [rep orientation];
NSLog(@"Orientation = %d", orientation);
CGImageRef iref = [rep fullResolutionImage];
if (iref) {
UIImage *largeimage = [UIImage imageWithCGImage:iref scale:1.0 orientation:orientation];
NSData *webData = UIImageJPEGRepresentation(largeimage,0.5);
[webData writeToFile:imagePath atomically:YES];
// Upload the image