photokit

Fetch only photos of type PHAssetMediaTypeImage form asset collection type PHAssetCollectionTypeSmartAlbum

帅比萌擦擦* 提交于 2019-12-09 08:05:24
问题 I am using the Photos framework to fetch album list in iOS8. I am able to do it using PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular options:nil]; This gives me a list of all smart albums including videos. How can I filter out videos from this list. I need only images. Help would be appreciated. Thanks. 回答1: You should set up fetch options, its has a property predicate , which can be

PhotoKit iOS8 - Retrieve image using the “PHImageFileURLKey”

只愿长相守 提交于 2019-12-08 09:12:54
问题 Is there anyway I can use the Path returned from the "PHImageFileURLKey" to go into the photo library and retrieve the image? The path returned is in this format: "file:///var/mobile/Media/DCIM/102APPLE/IMG_2607.JPG" My plan is to store this path in the database and use it to fetch the image when I need to get it back. Any help is appreciated. Thank you! 回答1: I think your solution of retrieving Photo Kit asset from the URL is wrong. Here is what I would do (supposing you have access to

iOS Photo Library read access

左心房为你撑大大i 提交于 2019-12-07 07:32:26
问题 After the user gave us permission to access his Camera Roll. We would like to grab the data and upload it to our services from inside our app. Is there a way to access the video data from the file? The only way to open the video file is to create an AVAsset. But that's not enough for me. I'm aware off func requestExportSessionForVideo(_ asset: PHAsset!, options options: PHVideoRequestOptions!, exportPreset exportPreset: String!, resultHandler resultHandler: ((AVAssetExportSession!, [NSObject

Given a CIImage, what is the fastest way to write image data to disk?

强颜欢笑 提交于 2019-12-07 06:58:13
问题 I'm working with PhotoKit and have implemented filters users can apply to photos in their Photo Library. I am currently obtaining the image, applying a filter, returning the edited version as a CIImage , then I convert the CIImage into NSData using UIImageJPEGRepresentation so I may write that out to disk. While this works beautifully, when users attempt to edit really large (like 30 MB) photos it can take upwards of 30 seconds for this to occur, with 98% of the time spent on

IOS8. Photos application bug?

丶灬走出姿态 提交于 2019-12-06 05:17:34
When I use filters in standard Photos application in IOS8, I can't get full metadata. I try two methods fetch metadata: [manager requestImageDataForAsset:asset options:options resultHandler:^(NSData *imageData, NSString *dataUTI, UIImageOrientation orientation, NSDictionary *info) { CIImage *ciimage = [CIImage imageWithData:imageData]; NSMutableDictionary *exif = [NSMutableDictionary dictionary]; [exif addEntriesFromDictionary:ciimage.properties]; }]; [asset requestContentEditingInputWithOptions:editOptions completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) {

iOS Photo Library read access

拟墨画扇 提交于 2019-12-05 12:33:43
After the user gave us permission to access his Camera Roll. We would like to grab the data and upload it to our services from inside our app. Is there a way to access the video data from the file? The only way to open the video file is to create an AVAsset. But that's not enough for me. I'm aware off func requestExportSessionForVideo(_ asset: PHAsset!, options options: PHVideoRequestOptions!, exportPreset exportPreset: String!, resultHandler resultHandler: ((AVAssetExportSession!, [NSObject : AnyObject]!) -> Void)!) -> PHImageRequestID But in my case I just want to upload the video to our

Crash upon CGImageDestinationFinalize

泄露秘密 提交于 2019-12-05 01:17:36
My app allows users to edit photos using the Photos framework. I am seeing some crash reports, and it appears the crash occurs when generating the output image, but I am not sure where the problem lies. This crash is occurring on multiple hardware devices and multiple versions of iOS 9 including the latest 9.1. The last call my app makes is CGImageDestinationFinalize in order to create the edited image NSData . The crash reports show that calls continue in the CoreImage space before the crash occurs in what appears to be GLTextureManager. Could this an out of memory issue? Do you see the issue

PHPhotoLibrary error while saving image at url

我只是一个虾纸丫 提交于 2019-12-04 01:29:03
问题 I create an image at url provided by PHContentEditingOutput . When I load data to UIImage and save it like this - it works. [[PHPhotoLibrary sharedPhotoLibrary] performChanges:^{ NSData *data = [NSData dataWithContentsOfURL:contentEditingOutput.renderedContentURL] UIImage *image = [UIImage imageWithData:data]; [PHAssetChangeRequest creationRequestForAssetFromImage:image]; } completionHandler:^(BOOL success, NSError *error) { ... }]; But when I try approach with url it fails: [[PHPhotoLibrary

Applying metadata to image causes performChanges request to fail

限于喜欢 提交于 2019-12-03 15:04:02
问题 I am using PhotoKit to edit photos and I need to preserve the metadata from the original photo. To do so I save the metadata then provide it to the options parameter in CGImageDestinationAddImage . I am able to finalize it and write it to disk successfully, but when I call performChanges to commit the asset edit, it fails. If I instead provide nil for options it will succeed. What is going wrong here? asset.requestContentEditingInputWithOptions(options) { (input: PHContentEditingInput!, _) ->

PHImageResultIsDegradedKey/PHImageFileURLKey is not found

…衆ロ難τιáo~ 提交于 2019-12-03 14:47:43
iOS 13 beta4 no longer gives 1) PHImageFileURLKey 2) PHImageResultIsDegradedKey in image result info keys. Anyone knows a way to find the fileurl of the PHAsset? You have to use this function from PHAsset object: - (PHContentEditingInputRequestID)requestContentEditingInputWithOptions:(nullable PHContentEditingInputRequestOptions *)options completionHandler:(void (^)(PHContentEditingInput *__nullable contentEditingInput, NSDictionary *info))completionHandler; Then you can retrieve URL this way: NSURL *url = contentEditingInput.fullSizeImageURL; Some example Objective-C code for anyone else