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
5
votes
0 answers

Saving photo with metadata into Camera Roll with specific file name

I'm trying to save an image with exif metadata using following code: +(void)saveImageWithMetaToCameraRoll:(UIImage*)image location:(CLLocation*)location album:(PHAssetCollection *)album exif:(NSDictionary *)metadata isOriginal:(BOOL)isOriginal…
Dmitry Klimkin
  • 445
  • 3
  • 15
5
votes
1 answer

PHAssets/PHAssetCollection/PHCollectionList and Folders

I am following Apple's Sample code 'ExampleappusingPhotosframework'. In the subject of PHAssets/PHAssetCollection, I noticed there is the possibility of 'Folders' being present. These can appear from being created be Mac's Photo's App, or an older…
Gizmodo
  • 3,151
  • 7
  • 45
  • 92
5
votes
3 answers

How to get Original Image and media type from PHAsset?

My **GMImagePickerController** returns the list of selected images from photos app. The code are as follows. - (void)assetsPickerController:(GMImagePickerController *)picker didFinishPickingAssets:(NSArray *)assetArray { …
Mitesh Dobareeya
  • 970
  • 1
  • 11
  • 36
5
votes
2 answers

Accessing iCloud photos uniquely on multiple devices using PHAsset

Is there a way of accessing a specific PHAsset in an iCloud album uniquely on multiple devices? I have written a simple app that lists thumbnails and .localIdentifiers from an iCloud shared album, and (naturally) it shows the same images on…
Grimxn
  • 22,115
  • 10
  • 72
  • 85
5
votes
2 answers

How to get file size of PHAsset?

Suppose there is a PHAsset representing image. How to get file size of the image? The only way I see is using valueForKey: with private ALAssetURL key, and retrieving size of ALAssetRepresentation, but apple can reject such app.
kelin
  • 11,323
  • 6
  • 67
  • 104
5
votes
1 answer

Smart way to group PHAsset fetch results by date

Is there a smarter/more proper way compared to what I am doing? I created a dictionary and go on enumerating and filling the year/month/date by looking at each fetched asset. let assetFetchResult = PHAsset.fetchAssetsInAssetCollection(album,…
KalanyuZ
  • 672
  • 6
  • 15
5
votes
0 answers

Hide UIProgressView after fetch for PHAsset is completed and progress finished animating

I'm performing a request to get an image asset given a PHAsset, and I'm using UIProgressView to indicate the progress using the progressHandler PHImageRequestOptions allows me to provide. When that handler is called, it provides me with progress so…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
5
votes
2 answers

Fetch only albums in a PHCollectionList

A PHCollectionList is a folder that could contain any number of albums and/or folders. I am currently fetching the collections within the list via PHCollection.fetchCollectionsInCollectionList(list, options: nil). This could return objects of type…
Jordan H
  • 52,571
  • 37
  • 201
  • 351
5
votes
2 answers

PHImageManager crashing after many image requests

I'm trying to grab all of the users PHAsset with PHAssetMediaTypeImage and then iterate through them, getting the corresponding UIImages one at a time. I have about 2k photos on my iPhone 5 and this code crashes after iterating through 587 of them.…
4
votes
1 answer

Get PHAsset/localIdentifier of image saved to photo library

I'm using UIImageWriteToSavedPhotosAlbum to save images to the Photos app. This was the only function I found that lets you do this. Here's my code: import UIKit import Photos class ViewController: UIViewController { /// photo of a cactus …
aheze
  • 24,434
  • 8
  • 68
  • 125
4
votes
1 answer

PHPickerViewController load videos via PHAsset

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 =…
Deepak Sharma
  • 5,577
  • 7
  • 55
  • 131
4
votes
2 answers

Get the same NSData of PHAsset after save

Do you know is there any way to get the same NSData of Image ( JPG , PNG ) after save with PHPhotoLibrary or no? OfC, iOS will modify some metadata and EXIF-- > ( Timestamp,... )data after save but, I'm asking about UIImage Data (include same EXIF…
Mo Farhand
  • 1,144
  • 8
  • 21
4
votes
0 answers

Displaying Depth Map from PHAsset

I am trying to read the depth map and overlay it over the UIImageView of a PHAsset. So far I have this: PHImageManager.default().requestImageData(for: self.asset!, options: nil, resultHandler:{ (data, responseString, orientation, info) -> Void in …
Gizmodo
  • 3,151
  • 7
  • 45
  • 92
4
votes
0 answers

In what cases will a PHAsset instance not have a creationDate?

I'm currently writing my first app and deal with PHAssets quite a bit. One attribute of PHAsset that is particularly important for what I'm trying to achieve is creationDate. This value is optional, so there are times when it can be…
Meg
  • 41
  • 1
4
votes
2 answers

How to get all PHAssets from MacOS's Photo Library

I want to parse all images from my MacOS Photos Library, using PHAsset. However all examples I find are only working for iOS, like the one below, where the last line, which retrieves the assets is not available on macos framework: NSMutableArray…
Laurent Crivello
  • 3,809
  • 6
  • 45
  • 89