gpt4 book ai didi

ios - 保存照片和检索 Assets 时,应用程序图片中的 Swift Camera 不保存 GPS 信息?

转载 作者:行者123 更新时间:2023-11-30 11:40:16 25 4
gpt4 key购买 nike

我正在使用相机和 UIImagePickerController 拍照,然后使用

将其保存到相册中
@objc func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) {

ImagePicker.dismiss(animated: true, completion: nil)
photoChanged = true

let image: UIImage = info[UIImagePickerControllerOriginalImage] as! UIImage
let compressedImage = image.resizeWithWidth(width: 450)
let ext: String = "JPEG"

UIImageWriteToSavedPhotosAlbum(image, self, #selector(image(image:didFinishSavingWithError:contextInfo:)), nil)
submittedPhoto = Photo(photo: compressedImage, ext: ext, key: nil, idx: nil, postId: post?.postId)

if let cell = tableView.cellForRow(at: IndexPath(row: 1, section: 0)) as? SubmitHunterTVC {

cell.addPhotoB.iconImageView.image = image
cell.addPhotoB.iconImageView.contentMode = .scaleAspectFill
cell.addPhotoB.clipsToBounds = true
}
tableView.reloadData()
}

当我检索 Assets 并检查位置时,我从 EXIF 和 Assets 中获得空的 {GPS} 信息。

E7F0DDE0-3A89-4E77-AF0C-2AED2A4F96FF/L0/001 mediaType=1/0,sourceType=1,(3024x4032),creationDate=2018-03-18 22:19:36 +0000,位置=0,隐藏=0,收藏=0

最佳答案

有一个很好的答案 HERE ,下面是该答案中的一些代码,它可能需要更新为当前语法:

func addAsset(image: UIImage, location: CLLocation? = nil) {
PHPhotoLibrary.shared().performChanges({
// Request creating an asset from the image.
let creationRequest = PHAssetChangeRequest.creationRequestForAsset(from: image)
// Set metadata location
if let location = location {
creationRequest.location = location
}
}, completionHandler: { success, error in
if !success { NSLog("error creating asset: \(error)") }
})
}

关于ios - 保存照片和检索 Assets 时,应用程序图片中的 Swift Camera 不保存 GPS 信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49353400/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com