0

I am making landscape app, I need to pick only landscape photos from the Photo Library, How do I fetch photos only in landscape?

Ahmad F
  • 30,560
  • 17
  • 97
  • 143
Maha Khan
  • 33
  • 3

2 Answers2

0

Filter the images using the image.imageOrientation property.

UIImageOrientation ref - Here

You can use PHAsset class to fetch all the images with required specification by using predicate.And then filter the images based on the image.imageOrientation

Eg:-

let options = PHFetchOptions()    
options.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]

var images = PHAsset.fetchAssets(with: .image, options: options)

PHClass - Ref

user3608500
  • 835
  • 4
  • 10
0

you need get size image . with > height ==> it is landscape

Ken Nguyen
  • 106
  • 5