When using the built in UIImagePicker from iOS the developer has access to the thumbnail image used in the picker. Is it possible to access the thumbnail used by Filepicker or otherwise access the ALAsset library URL used by Filepicker?
Thumbnail from filepicker on iOS
Asked Answered
As a side note the online docs state that there will be a key in the info dictionary returned from the picker that contains an ALAsset library URL, however in practice the key does not exist. –
Perzan
Ahh I see there are two callbacks the first of which supplies the thumbnail image; Is there a way to access the ALAsset if that was originally the source? –
Perzan
Hi Kyle. The docs have been updated to reflect the fact that only a thumbnail gets returned on the didPickMediaWithInfo call. The ALAsset will come back on the didFinishPickingMediaWithInfo call. –
Sahara
Liyan I never get an ALAsset library URL back from the FPPicker didFinishPickingMediaWithInfo callback, only file://location/of/my/image/in/a/tmp/dir/inside/application/bundle –
Perzan
Hi Kyle. Yes. It looks like we are returning a file://... location. Can I ask why the ALAAsset library URL would be helpful? –
Sahara
Using the Javascript API one of the things we are able to do is collect the meta data about a particular file. If the ALAsset URL was supplied the associated meta data would be available immediately without making a second request (important for battery to try and make as few requests as possible, slower, etc...). –
Perzan
This how I did it, but I must warn you it is slow(ish) and frameworks needed to to this are memory intensive as it iterates over the ALAssetsLibrary looking for posterimages. This on the background thread, so UI changes are sent to the main thread for rendering.
self.assetsLibrary = [[ALAssetsLibrary alloc] init];
NSUInteger groupTypes = ALAssetsGroupAlbum | ALAssetsGroupSavedPhotos | ALAssetsGroupPhotoStream;
[self.assetsLibrary enumerateGroupsWithTypes:groupTypes
usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
if (group.posterImage != nil) {
dispatch_async(dispatch_get_main_queue(), ^{
self.pictureLayer.contents = (__bridge_transfer id) CGImageCreateCopy(group.posterImage);
[self.layer setNeedsDisplay];
self.assetsLibrary = nil;
*stop = YES;
});
}
}
failureBlock:^(NSError *error) {
self.assetsLibrary = nil;
NSLog(@"AssetLib error:%@",error);
}];
© 2022 - 2024 — McMap. All rights reserved.