iOS获取图片的信息

相册中的图片需要使用 Assets Library Framework 配合获取图片信息

// Get the assets library
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];

// Enumerate just the photos and videos group by using ALAssetsGroupSavedPhotos.
[library enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
usingBlock:^(ALAssetsGroup *group, BOOL *stop)
{

// Within the group enumeration block, filter to enumerate just photos.
[group setAssetsFilter:[ALAssetsFilter allPhotos]];

// For this example, we’re only interested in the first item.
[group enumerateAssetsAtIndexes:[NSIndexSet indexSetWithIndex:0]
options:0
usingBlock:^(ALAsset *alAsset, NSUInteger index, BOOL *innerStop)
{

// The end of the enumeration is signaled by asset == nil.
if (alAsset) {
ALAssetRepresentation *representation = [alAsset defaultRepresentation];
NSDictionary *imageMetadata = [representation metadata];
// Do something interesting with the metadata.
}
}];
}
failureBlock: ^(NSError *error)
{
// Typically you should handle an error more gracefully than this.
NSLog(@”No groups”);
}];

[library release];