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
9
votes
4 answers

How to fetch all images from custom Photo Album - Swift

How to fetch all images from custom Photo Album? var fetchOptions = PHFetchOptions() fetchOptions.sortDescriptors = [NSSortDescriptor(key:"creationDate", ascending: false)] fetchOptions.predicate = NSPredicate(format: "mediaType = %d",…
fatihyildizhan
  • 8,614
  • 7
  • 64
  • 88
9
votes
3 answers

PHImageManager's method "requestImageDataForAsset" gives crash in Swift

I am using PHImageManagers's requestImageDataForAsset to calculate memory size of particular photos in camera roll. It is working fine in my device but some users getting countinous crash after calculate memory size (found by analytics and crash…
Madhubalan K
  • 357
  • 5
  • 21
9
votes
2 answers

PHAsset returned from fetchAssetsWithALAssetURLs: is always nil when choosing a photo from the "My Photo Stream" album using UIImagePickerController

I am using a UIImagePickerController to let the user choose a photo or video to share in the app. When the user chooses a media item in their Library, I execute this code in one of the UIImagePickerController's delegate methods: -…
8
votes
2 answers

iOS 14 Beta check PHAsset permissions for .limited access level

in iOS 14 beta, is there a way to check if the app has permissions to load a PHAsset image before trying to load it with PHImageManager.requestImage? This is for PHAuthorizationStatus.limited - when I fetch all assets in a PHAssetCollection, it…
kzamanov
  • 81
  • 6
8
votes
1 answer

Modifing metadata from existing phAsset seems not working

In my App I want to make it possible, that the user sets an StarRating from 0 to 5 for any Image he has in his PhotoLibrary. My research shows, that there are a couple of ways to get this done: Save the exif metadata using the new…
Marcel T
  • 659
  • 1
  • 7
  • 28
8
votes
1 answer

Sharing Video PHAsset via UIActivityController

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: …
Gizmodo
  • 3,151
  • 7
  • 45
  • 92
8
votes
2 answers

Getting size (height and width) from PHAsset

Is there a way to get the height and width of the image from a PHAsset object. I'm trying to make an image picker with a custom UICollectionViewLayout (Kind of like the main page of Pinterest app) I'v fetched all of the photos from the photo library…
8
votes
3 answers

Getting the URL of picture taken by camera with Photos Framework

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…
8
votes
2 answers

Get PHAsset from iOS Share Extension

I am developing a share extension for photos for my iOS app. Inside the extension, I am able to successfully retrieve the UIImage object from the NSItemProvider. However, I would like to be able to share the image with my container app, without…
haplo1384
  • 1,206
  • 1
  • 12
  • 29
8
votes
1 answer

PHChange changeDetailsForFetchResult - always returns nil

I am using the PHPhotoLibrary to retrieve several photo collections like this: _smartAlbumsFetchResult = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumMyPhotoStream…
Sebastian Krogull
  • 1,468
  • 1
  • 15
  • 31
8
votes
3 answers

PHAsset (or ALAsset) cross-device identifier

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…
Lucio
  • 632
  • 5
  • 21
7
votes
2 answers

Deleting photo from Photo Library using Photo framework

I am writing a photo album app which can access the photo from the user's photo library, add filter, and delete photo. I used the Photo framework to delete an asset with PHAssetChangeRequest.deleteAssets(assetToDelete). The class of asset here is…
Ron
  • 110
  • 1
  • 9
7
votes
2 answers

Swift - Get Image creationDate and Location

A function in my app returns an image and I'm now trying to get the images creationDate and location. How is this possible with/without using PHAsset?
pjmanning
  • 1,241
  • 1
  • 20
  • 48
7
votes
2 answers

PHAsset: Saving a new image with metadata

I'm using a UIImagePickerController to allow the user to take a picture with the camera. When the delegate's called, I want to save the image to the photo library/camera roll, which I do using PHAssetChangeRequest. The issue is the documentation…
livings124
  • 1,103
  • 1
  • 10
  • 23
7
votes
1 answer

PHAssetCollectionChangeRequest: addAssets() now accepts NSFastEnumeration. how to achieve this?

My Application tries to import an image from photos and adds to an album. But in latest swift changes. addAssets() accepts parameter as NSFastEnumeration. So I get an error as shown in the image. even the Apple API document has this same code:…
Imran
  • 769
  • 1
  • 9
  • 21
1 2
3
30 31