I am making landscape app, I need to pick only landscape photos from the Photo Library, How do I fetch photos only in landscape?
Asked
Active
Viewed 420 times
2 Answers
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
-
First of all thanks means, I need to fetch all images from photo library and then check its orientation. – Maha Khan Jan 17 '17 at 07:51
-
yes..Are you using PHAsset class to get images or UIIMagePickerController? – user3608500 Jan 17 '17 at 08:05
-
PHAsset does not provide any predicate or subtype to show image picker only landscape photos ?, I need to create custom picker – Maha Khan Jan 17 '17 at 08:08
-
Yes...there is no predicate to identify the image orientation. – user3608500 Jan 17 '17 at 08:16
-
Using custom picker will you able to access multiple images at same time? – user3608500 Jan 17 '17 at 08:17
-
Or you can use "pixelWidth" and "pixelHeight" properties to identify the orientation by comparing the height and width. – user3608500 Jan 17 '17 at 09:22