phasset

How to upload PHAsset (video and image only)?

心不动则不痛 提交于 2021-01-27 19:05:05
问题 I want to upload PHAsset but I do not have the file path of the asset. I am able to upload the file using the below block methods. But these are asynchronous methods to get the URLs. Is there any synchronous method to do so or any other way to upload the PHAsset files. Image Asset URL: [asset requestContentEditingInputWithOptions:editOptions completionHandler:^(PHContentEditingInput *contentEditingInput, NSDictionary *info) { NSURL *imageURL = contentEditingInput.fullSizeImageURL; }]; Video

PHPickerViewController load videos via PHAsset

僤鯓⒐⒋嵵緔 提交于 2020-12-15 05:49:16
问题 PHPickerViewController allows access to copies of photo library assets as well as returning PHAssets in the results. To get PHAssets instead of file copies, I do: let photolibrary = PHPhotoLibrary.shared() var configuration = PHPickerConfiguration(photoLibrary: photolibrary) configuration.filter = .videos configuration.selectionLimit = 0 let picker = PHPickerViewController(configuration: configuration) picker.delegate = self self.present(picker, animated: true, completion: nil) And then, /

Get file size of PHAsset without loading in the resource?

做~自己de王妃 提交于 2020-02-18 19:57:29
问题 Is there a way to get the file size on disk of a PHAsset without doing requestImageDataForAsset or converting it to ALAsset ? I am loading in previews of a user's photo library - potentially many thousands of them - and it's imperative to my app that they know the size before import. 回答1: You can grab the fileSize of a PHAsset and convert it to human readable form like this: let resources = PHAssetResource.assetResources(for: yourAsset) // your PHAsset var sizeOnDisk: Int64? = 0 if let

Get file size of PHAsset without loading in the resource?

放肆的年华 提交于 2020-02-18 19:57:11
问题 Is there a way to get the file size on disk of a PHAsset without doing requestImageDataForAsset or converting it to ALAsset ? I am loading in previews of a user's photo library - potentially many thousands of them - and it's imperative to my app that they know the size before import. 回答1: You can grab the fileSize of a PHAsset and convert it to human readable form like this: let resources = PHAssetResource.assetResources(for: yourAsset) // your PHAsset var sizeOnDisk: Int64? = 0 if let

How To Paginate when using PHAsset to Fetch User Photo library

自作多情 提交于 2020-01-21 09:16:05
问题 I am asking the same question as here I do not understand how to implement to solution. I have tried the following fileprivate func fetchPhotos(indexSet: IndexSet) { let allPhotos = PHAsset.fetchAssets(with: .image, options: assetsFetchOptions()) DispatchQueue.global(qos: .background).async { allPhotos.enumerateObjects(at: indexSet, options: NSEnumerationOptions.concurrent, using: { (asset, count, stop) in let imageManager = PHImageManager.default() let targetSize = CGSize(width: 200, height:

PHAsset (or ALAsset) cross-device identifier

偶尔善良 提交于 2020-01-13 10:24:10
问题 I am actually creating an iOS app, and want to store some details about Photo Library pictures in an SQLite database. I also would like to be able to share this data across the different devices the user has (imagine someone wanted to reorganize pictures on his iPhone, and wants to retrieve the same order in his iPad). I have searched across the Apple documentation, but did not find any PHAsset identifier that is shared across devices. I also tried to check if the PHImageFileURLKey ,

How to I extract a PHAsset's Location property?

痞子三分冷 提交于 2020-01-06 14:09:44
问题 Xcode says that PHAsset doesn't have the 'location' member. What's the remedy for Swift? 回答1: Short answer: you might have forgotten to import CoreLocation; import Photos import CoreLocation let asset: AnyObject? = nil if let asset = asset as? PHAsset { let location = asset.location } When I remove the CoreLocation import, I can replicate your error. 来源: https://stackoverflow.com/questions/30249163/how-to-i-extract-a-phassets-location-property

While converting PHAsset to UIImage losing transparency

穿精又带淫゛_ 提交于 2020-01-02 08:00:30
问题 After I pick an image from Image picker and try to convert PHAsset to UIImage image is losing transparency of the png Image. I tried searching everywhere but didn't find anything about it. func getAssetThumbnail(asset: PHAsset) -> UIImage { let manager = PHImageManager.defaultManager() let option = PHImageRequestOptions() var thumbnail = UIImage() option.synchronous = true manager.requestImageForAsset(asset, targetSize: CGSize(width: 341.0, height: 182.0), contentMode: .AspectFit, options:

Swift - Playing Videos from iOS PHAsset

社会主义新天地 提交于 2019-12-31 12:35:12
问题 I want to play video from PHAsset , collected from iOS Photos. PHAsset video nsurl (https://stackoverflow.com/a/35099857/1084174) is valid to my own application lets say MyPlayer for few moments/blocks. When I am copying the image/video into MyPlayers own sandbox only then the nsurl becomes always valid. It seems to me, I need to copy each video from temporary PHAsset nsurl to MyPlayers sandbox (appgroup/documents) and only then I can play the video with sandbox relative nsurl. If this is the