1

I'm building an app that deals with images taken in Portrait Mode (Depth Effect). I need to present UIImagePickerController to only display photos that have depth effect.

How do I achieve this?

Can Poyrazoğlu
  • 33,241
  • 48
  • 191
  • 389

1 Answers1

2

This is not possible with the public methods of UIImagePickerController. Use a custom image picker for this.

For checking if a specific PHAsset has a depth effect, check whether its mediaSubtypes property is equal to .photoDepthEffect:

if asset.mediaSubtypes == .photoDepthEffect {
    //live photo          
}
Tamás Sengel
  • 55,884
  • 29
  • 169
  • 223
  • 1
    Yeah, I ended up writing a custom collection view controller that accesses photo library using `[PHAssetCollection fetchAssetCollectionsWithType:PHAssetCollectionTypeSmartAlbum subtype:PHAssetCollectionSubtypeSmartAlbumDepthEffect options:nil]` method. – Can Poyrazoğlu Dec 13 '18 at 23:01
  • 1
    Note that it is probably better to use `PHFetchOptions` with a predicate of `(mediaSubtype & %d) != 0` where `%d` is the raw value of the required media subtype, than to fetch everything and manually remove those with the wrong subtype. – Ash Dec 24 '18 at 08:53
  • @Ash I agree with that, yes. – Tamás Sengel Dec 24 '18 at 20:25