Questions tagged [phasset]

A `PHAsset` is an object in the iOS Photos Framework (aka PhotoKit) that represents an image or video file on the iOS device.

A PHAsset object represents an image or video file that appears in the Apple Photos app, including iCloud Photos content.

To display or edit assets, use the PHAsset class to fetch asset objects for the photos or videos you want to work with. An asset object is immutable and contains only the metadata for the photo or video it represents.

For more detailed info: https://developer.apple.com/documentation/photokit/phasset

451 questions
4
votes
1 answer

Get an edited photo's URL from PHAsset

I'm trying to get a photo's URL from a PHAsset using this code. let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions() options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in return…
Max Wang
  • 247
  • 3
  • 16
4
votes
1 answer

iOS: PHAsset & Detecting DNG RAW Format

I got Apple's sample code for 'SamplePhotosApp' and in the photo album grid photo layout, trying to detect DNG RAW files (put up a badge if it's DNG). Default cellForItemAt: override func collectionView(_ collectionView: UICollectionView,…
Gizmodo
  • 3,151
  • 7
  • 45
  • 92
4
votes
0 answers

Fetch PHAssets that don't belong to any PHAssetCollection

Is it possible to fetch all PHAssets that don't belong to any PHAssetColletion? Basically what I want to achieve is to get all photos that are not sorted to any album. I know I can do this: let photos = PHAsset.fetchAssets(with:…
4
votes
1 answer

fetch videos with duration less than 10 seconds

I am integrating custom image picker and i have to show videos from camera roll whose duration is less than 10 seconds. Below code fetches all videos from gallery but i want to apply predicate to filter based on duration as well. let options =…
khushboo
  • 260
  • 2
  • 12
4
votes
2 answers

How to get original (EXIF?) creation date/time of PHAsset?

PHAsset has a creationDate property that gives the creation date of the asset in UTC. If I take a photo taken at 10:52 PM UTC-6, the creationDate property is 03:52 AM. How am I supposed to know the 'true' time of the photo taken? No timezone…
Zach
  • 3,909
  • 6
  • 25
  • 50
4
votes
2 answers

Load Images From PHAsset into an Imageview

I'm new in Swift. In the following code, it retrieve photos and put them in an array. Now I want to show them in imageviews. How can I do it? I mean how ,for example, show an element of the array in an imageview. var list :[PHAsset] =…
A.bee
  • 502
  • 5
  • 16
4
votes
0 answers

Download large number PHAssets from iCloud

I am working on an app that backs up a user's photo library to a flash drive. The issue I am running into is with photos that are stored in iCloud. When the user has the 'Optimize Storage' option enabled, there can be thousands of photos stored in…
Shawney
  • 143
  • 11
4
votes
1 answer

FetchAssetsWithLocalIdentifiers returns empty array

I'm using Photos.Framework to save photos taken from the camera into my gallery and to retrieve them. This is the code I'm using to store the photos: __block PHAssetCollection *album = [self getMyAlbumWithName:@"MyAlbumName"]; if(album ==…
Wonton
  • 1,033
  • 16
  • 33
4
votes
2 answers

How to share PHAsset by using UIActivityViewController?

I'm now trying to share Phasset (video or image) through UIActivityViewController. AFAIK I used to share image or video located in my document directory by giving url to array and using like this [[UIActivityViewController alloc]…
Hwangho Kim
  • 629
  • 4
  • 20
4
votes
1 answer

PHCachingImageManager issue on iPad on iOS 9.3

Only on iPad devices and only in latest 9.3 release, when you call [PHCachingImageManager requestImageForAsset:] with a legitimate target size (CGSize) it does not return a valid image. For example... PHAsset *asset =…
mutable2112
  • 439
  • 4
  • 15
4
votes
1 answer

Swift - NSCoder and PHAsset

I have this code: import Foundation import Photos class PostItem: NSObject, NSCoding { var postDate: String? var postTitle: String? var postText: String? var postImages: [PHAsset]? func encodeWithCoder(aCoder: NSCoder) { …
4
votes
2 answers

How to get NSData from file by using PHAsset

I have file at path file:///var/mobile/Media/DCIM/100APPLE/IMG_0197.mov But when I try this code- NSError *error; NSData *data = [NSData dataWithContentsOfFile:assetUrl.relativePath options:NSDataReadingMappedAlways error:&error]; I got nothing…
Dmitry Nelepov
  • 7,246
  • 8
  • 53
  • 74
4
votes
1 answer

ALAssetLibrary , it only shows partial number of photos in All Photos on some devices

I used to use ALAsset, it works well for iOS7~iOS9 for most users (about 100K) . But some users complain it only show partial number of photos on i6 device, ios8/ios9. (Maybe 1% has this problem, I'm not sure.) I have the i6 ios9 device, but…
Bruce Tsai
  • 1,440
  • 2
  • 12
  • 18
4
votes
1 answer

How to fetch newly created object from PHObjectPlaceholder after change request completes

I'm using the new Photos framework and I'm saving a video to my photo roll: let assetRequest = PHAssetChangeRequest.creationRequestForAssetFromVideoAtFileURL(url) assetPlaceHolder = assetRequest?.placeholderForCreatedAsset A short time later…
nwales
  • 3,521
  • 2
  • 25
  • 47
4
votes
2 answers

PHAsset doesn't reflect change after PHAssetChangeRequest completes

In the docs it says: After Photos runs the change block and calls your completion handler, the asset’s state reflects the changes that you requested in the block. However, inside the completion handler (as well as after the completion…
Kenny Wyland
  • 20,844
  • 26
  • 117
  • 229