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

442 questions
59
votes
9 answers

PHAsset to UIImage

I'm attempting to create a UIImage (like a thumbnail or something) from a PHAsset so that I can pass it into something that takes a UIImage. I've tried adapting solutions I found on SO (since they all just directly pass it into say a tableview or…
dcheng
  • 1,673
  • 1
  • 9
  • 19
52
votes
3 answers

Determine largest PHAsset image size available on iOS device

How can I determine the largest PHAsset image size that is available on an iOS device, where by "available" I mean currently on the device, not requiring any network download from iCloud Photo Library? I've been developing an app where a collection…
mluisbrown
  • 12,738
  • 6
  • 50
  • 81
40
votes
10 answers

NSURL from PHAsset

I'm converting our app over to use the Photos Framework of iOS8, the ALAsset framework is clearly a second class citizen under iOS8. I'm having a problem is that our architecture really wants an NSURL that represents the location of the media on…
Paul Cezanne
  • 8,560
  • 7
  • 55
  • 85
38
votes
5 answers

Save images with phimagemanager to custom album?

I am making an app that takes pictures with AVFoundation and I want to save them to a custom album that I can then query and show in my app. (I'd prefer to not have them in the general photo roll, unless the user wants that) I can't really find…
Jonovono
  • 2,517
  • 6
  • 26
  • 49
22
votes
5 answers

How to identify if a PHAsset is not completely downloaded from iCloud (so I need to request again with options.networkAccessAllowed)

The docs say: PHImageResultIsInCloudKey: A Boolean value indicating whether the photo asset data is stored on the local device or must be downloaded from iCloud. (NSNumber) If YES, no image was provided, because the asset data must be…
Thyraz
  • 2,292
  • 2
  • 17
  • 21
22
votes
7 answers

iOS8 Photos Framework: How to get the name(or filename) of a PHAsset?

Im trying to get the image name using PHAssets. But I couldn't find metadata for filename or any method to get the image name. Is there a different way to get the file name?
Priyanka
  • 492
  • 1
  • 5
  • 13
21
votes
5 answers

How to get an ALAsset URL from a PHAsset?

You can do it sneakily† using the undocumented PHAsset.ALAssetURL property, but I'm looking for something documented. † In Objective-C, this will help @interface PHAsset (Sneaky) @property (nonatomic, readonly) NSURL *ALAssetURL; @end
Clay Bridges
  • 10,746
  • 10
  • 62
  • 110
20
votes
4 answers

How to Play Videos PHAsset in iOS?

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…
Sazzad Hissain Khan
  • 29,428
  • 20
  • 134
  • 192
20
votes
4 answers

PHAsset get original file name

I wonder if there any way to get the original file name using PHAsset? I use the following code to extract the file info. [[PHImageManager defaultManager] requestImageDataForAsset:asset options:requestOption resultHandler:^(NSData *imageData,…
ProblemSlover
  • 2,409
  • 2
  • 20
  • 32
19
votes
5 answers

Sorting photos exactly like native photoapp using PhotoKit

I am trying to reproduce the native iOS8 photopicker using Photos framework. I got a problem with the sorting. Lets say I do following: I edit a photo in Camera+ app and save it back to gallery. I favourite another photo. In the native…
knutigro
  • 1,014
  • 1
  • 9
  • 19
19
votes
6 answers

Get the local file path of a PHAsset

I have a photo I want my user to be able to share on Instagram and I need to get the local file directory of the photo. However I am fetching my images as a PHAsset (not the ALAsset all the other answers seem to cover on this subject). Looking at…
Aggressor
  • 12,511
  • 18
  • 88
  • 165
17
votes
5 answers

iOS 11: [ImageManager] Unable to load image data

After update to iOS 11, photo assets now load slowly and I get this message in console: [ImageManager] Unable to load image data, /var/mobile/Media/DCIM/103APPLE/IMG_3064.JPG I use static function to load image: class func getAssetImage(asset:…
Bio-Matic
  • 717
  • 8
  • 19
17
votes
6 answers

Check given PHAsset is iCloud asset?

I'm trying to get PhAsset object. I want to segregate iCloud assets. Here is my code, PHFetchResult *cloudAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeAlbum subtype:PHAssetCollectionSubtypeAny…
rishu1992
  • 1,344
  • 3
  • 12
  • 29
16
votes
2 answers

Fetch only photos of type PHAssetMediaTypeImage form asset collection type PHAssetCollectionTypeSmartAlbum

I am using the Photos framework to fetch album list in iOS8. I am able to do it using PHFetchResult *smartAlbums = [PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeAlbumRegular…
bhoomi
  • 363
  • 1
  • 4
  • 11
14
votes
6 answers

How to properly detect a PHAsset's file type (GIF)

I have no idea why this is so difficult. I'm trying to determine the file type of a PHAsset, specifically, I want to know if a given asset represents a GIF image or not. Simply inspecting the asset's filename tells me it's an MP4: [asset…
mitchtreece
  • 171
  • 2
  • 7
1
2 3
29 30