【发布时间】:2020-04-05 11:04:37
【问题描述】:
我正在创建一个相机应用程序,一切正常,但上传到 Firebase 的照片文件太大。它们属于 3MB 类别,我希望它们属于 ±600KB 类别。
我已将 AVCapturePhotoSettings.isHighResolutionPhotoEnabled 设置为 false 但这似乎没有任何作用,并且 AVCapturePhotoOutput.quality.balanced 仅适用于iOS13+ 在我的情况下不起作用。
这是将图像发送到我的 imageArray 的委托函数
extension NewPostFromPhoto: AVCapturePhotoCaptureDelegate {
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
if let error = error {
debugPrint (error)
} else {
photoData = photo.fileDataRepresentation()
UIImageWriteToSavedPhotosAlbum(UIImage(data: photoData!)!, nil, nil, nil)
self.imageArray.insert((UIImage(data: photoData!)?.fixOrientation())!, at:0)
self.recentMediaCollection.reloadData()
}
}
}
这是我的 takePhoto() 方法:
func takeNewPhoto () {
let settings = AVCapturePhotoSettings ()
settings.isHighResolutionPhotoEnabled = false
photoOutput?.capturePhoto(with: settings, delegate: self)
}
【问题讨论】:
标签: swift avcaptureoutput