Objective-C / ALAssetsLibrary - Find images informations and Exif informations

I'm trying to use the ALAssetsLibrary Class for retrieve the list of the photos inside the device and the relative informations about them. I have implemented a method that reveal correctly the number of images, but at the moment i don't know how can i find photos informations how width, height, orientation ecc… This is the code that i'm using:

ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
    if (group) {
        [group setAssetsFilter:[ALAssetsFilter allPhotos]];
        [group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop){
            if (asset){
                NSString *description = [asset description];
                NSLog(@"description %@", description);

            }
        }];
    }
} failureBlock:^(NSError *error) {
    NSLog(@"error enumerating AssetLibrary groups %@\n", error);
}];

Actually if i log the my NSString "description" variable, i receive these informations (for one example image):

"description ALAsset - Type:Photo, URLs:assets-library://asset/asset.JPG?id=766424BD-D28D-47F9-8E0F-AD8F19C4C732&ext=JPG"

Now, i need to understand how find the others information (width, height, name ect..) and if there is the possibility to access to the EXIF informations of the images.

Thanks

Answers


You were close. Instead of logging the description of the asset, you want to log the meta data of the default representation of the asset. The following will get you an NSDictionary containing the metadata for the image. Then you can access properties like height, width, etc with standard objectForKey calls.

ALAssetsLibrary* library = [[ALAssetsLibrary alloc] init];
[library enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
    if (group) {
        [group setAssetsFilter:[ALAssetsFilter allPhotos]];
        [group enumerateAssetsUsingBlock:^(ALAsset *asset, NSUInteger index, BOOL *stop){
            if (asset){

                NSDictionary *data = [[asset defaultRepresentation] metadata];
                NSLog(@"%@",data);
            }
        }];
    }
} failureBlock:^(NSError *error) {
    NSLog(@"error enumerating AssetLibrary groups %@\n", error);
}];

Need Your Help

XSP4 could not start, missing xsp4 assembly

asp.net-mvc-3 mono xsp slackware

I have a mono (2.10.7) instance running and I'm trying to code some ASP.NET MVC 3 application but I just hit a wall I don't know how to pass.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.