2012-03-16 62 views
3

我想通了如何使用AssestsLibrary獲得所有用戶的圖像在相機膠捲:獲取相機膠捲圖像及其EXIF數據?

- (void)updateLastPhotoThumbnail { 
ALAssetsLibrary *assetsLibrary = [[ALAssetsLibrary alloc] init]; 
[assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos usingBlock:^(ALAssetsGroup *group, BOOL *stop) { 
    NSInteger numberOfAssets = [group numberOfAssets]; 
    if (numberOfAssets > 0) { 
     NSLog(@"numberOfPictures: %d",numberOfAssets); 
     //NSInteger lastIndex = numberOfAssets - 1; 
     int i = 0; 
     for (i = 0; i <= numberOfAssets-1; i++) { 
      [group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:i] options:0 usingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) { 
       UIImage *thumbnail = [UIImage imageWithCGImage:[result thumbnail]]; 
       NSLog(@"theObject!!!! -- (%d) %@",i,thumbnail); 
       [cameraRollPictures addObject:thumbnail]; 
      }]; 
     } 
    } 
} failureBlock:^(NSError *error) { 
    NSLog(@"error: %@", error); 
}]; 

}

我成功創建UIIMages的數組,但我怎麼能得到從UIImages EXIF數據使用這個片段我有?

PS:我已經看過這http://code.google.com/p/iphone-exif,但我不能沒有錯誤地建立它。

回答

2

您無法從UIImage對象獲取元數據。 但是你可以查詢ALasset對象元數據:

NSDictionary *metadata = [[result defaultRepresentation] metadata]; 

廚師,

亨德里克

相關問題