I have a list of PHAssets that I need to get images from of a certain size.
To test this out, I give the size to be the size of the device screen
let manager = PHImageManager.default()
let option = PHImageRequestOptions()
option.isSynchronous = true
for asset in assets {
manager.requestImage(for: asset, targetSize: CGSize(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height), contentMode: .aspectFit, options: option, resultHandler: {(result, info)->Void in
//prints the proper bounds for a screen
print("width and height \(UIScreen.main.bounds.width) \(UIScreen.main.bounds.height)")
//prints 2304.0 3072.0 for width and height respectively
print("result size \(result!.size.width) \(result!.size.height)\n")
self.photos.append(result!)
})
}
I need the resulting photos to be cut to the size I specify, but they're off by over 2000 pixels. How do I resolve this?
Per Apple:
Since you want a specific size, then set the above option to force the request to respect your size.
Option