phasset

How to get MIME type for image or video in iOS 8 using PHAsset?

我怕爱的太早我们不能终老 提交于 2019-12-05 04:00:44
问题 I am using PHAsset in my application where I need to upload image and video to api, for that I need mime type of image and video. In previous version of iOS I was using following code but in iOS 8 I don't know how to get mimetype I have tried looking into apple PHAsset programming guide but unable to find it. ALAssetRepresentation *representation = [asset defaultRepresentation]; NSString *mimeType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass ((__bridge CFStringRef)

Getting the URL of picture taken by camera with Photos Framework

只愿长相守 提交于 2019-12-04 23:04:46
问题 I have an app that uses a UIImagePickerController to retrieve pictures both from camera and from the photos library. In the image picker delegate I only want to save the NSURL ( UIImagePickerControllerReferenceURL ) of the picked image to save memory. When the user needs to see the image later on, I load it with PHCachingImageManager directly from the photos library. Now - this whole thing works great with pictures the user chooses from the library, but not with pictures directly taken by

Extract video portion from Live Photo

非 Y 不嫁゛ 提交于 2019-12-04 09:48:02
问题 Has anyone figured out how to extract the video portion from a Live Photo? I'm working on an app to convert Live Photos into a GIF, and the first step is to get the video file from the Live Photo. It seems like it should be possible, because if you plug in your phone to a Mac you can see the separate image and video files. I've kinda run into a brick wall in the extraction process, and I've tried many ways to do it and they all fail. The first thing I did was obtain a PHAsset for what I think

Check given PHAsset is iCloud asset?

江枫思渺然 提交于 2019-12-04 09:28:54
问题 I'm trying to get PhAsset object. I want to segregate iCloud assets. Here is my code, PHFetchResult *cloudAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny options:nil]; [cloudAlbums enumerateObjectsUsingBlock:^(PHAssetCollection *collection, NSUInteger idx, BOOL *stop){ if(collection != nil){ PHFetchResult *result = [PHAsset fetchAssetsInAssetCollection:collection options:fetchOptions]; [result enumerateObjectsUsingBlock:

Sharing Video PHAsset via UIActivityController

半世苍凉 提交于 2019-12-04 05:39:23
I am trying to share video PHAsset via UIActivityController using requestAVAsset. This works with Messaging, but not with AirDrop, indicating as 'Failed'. PHCachingImageManager.default().requestAVAsset(forVideo: asset, options: nil, resultHandler: { (givenAsset, audioMix, info) in let videoAsset = givenAsset as! AVURLAsset let videoURL = videoAsset.url DispatchQueue.main.async { let activityViewController = UIActivityViewController( activityItems: [videoURL], applicationActivities: nil) activityViewController.excludedActivityTypes = [UIActivityType.saveToCameraRoll] if let

How to get MIME type for image or video in iOS 8 using PHAsset?

对着背影说爱祢 提交于 2019-12-03 20:28:10
I am using PHAsset in my application where I need to upload image and video to api, for that I need mime type of image and video. In previous version of iOS I was using following code but in iOS 8 I don't know how to get mimetype I have tried looking into apple PHAsset programming guide but unable to find it. ALAssetRepresentation *representation = [asset defaultRepresentation]; NSString *mimeType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass ((__bridge CFStringRef)[representation UTI], kUTTagClassMIMEType); Looking for any guidance. PHContentEditingInput has property

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

Phasset + AfNetworking Upload Multiple Videos

ぃ、小莉子 提交于 2019-12-03 09:47:29
问题 Currently I'm using the following code to upload videos: NSURLRequest *urlRequest = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:[[entity uploadUrl]absoluteString] parameters:entity.params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [UploadModel getAssetData:entity.asset resultHandler:^(NSData *filedata) { NSString *mimeType =[FileHelper mimeTypeForFileAtUrl:entity.fileUrl]; // NSError *fileappenderror; [formData

Phasset + AfNetworking Upload Multiple Videos

只愿长相守 提交于 2019-12-03 00:14:35
Currently I'm using the following code to upload videos: NSURLRequest *urlRequest = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:[[entity uploadUrl]absoluteString] parameters:entity.params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { [UploadModel getAssetData:entity.asset resultHandler:^(NSData *filedata) { NSString *mimeType =[FileHelper mimeTypeForFileAtUrl:entity.fileUrl]; // NSError *fileappenderror; [formData appendPartWithFileData:filedata name:@"data" fileName: entity.filename mimeType:mimeType]; }]; } error:&urlRequestError];