Get camera roll images and their EXIF data?

徘徊边缘 提交于 2019-12-10 09:58:56

问题


I figured out how to get all the user's images in the camera roll using the AssestsLibrary:

- (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);
}];

}

I successfully created the array of UIIMages, but how could I get EXIF data from the UIImages using this snippet I have?

PS: I've looked at this http://code.google.com/p/iphone-exif, but I cannot get it to build without errors.


回答1:


You can't get metadata from UIImage objects. But you can query an ALasset object for metadata:

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

Chefs,

Hendrik



来源:https://stackoverflow.com/questions/9730973/get-camera-roll-images-and-their-exif-data

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!