我目前正在尝试使用UIImagePickerController在应用程序中拍摄照片,将它们保存到本地数据库,然后稍后上传到服务中。
但似乎元数据(特别是EXIF)不会自动与图像捆绑。我已经尝试这样提取它:
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])
{
self.imageDelegate?.saveImage( image: info[UIImagePickerControllerOriginalImage] as! UIImage, metadata: (info[UIImagePickerControllerMediaMetadata] as? NSDictionary)! )
// ...
}
现在我已经有了图像和元数据,但是我该如何将它存储到JPEG文件中?我需要服务器上图像中的GPS数据。
我目前正在直接从相机卷中的UImage创建图像:
UIImageJPEGRepresentation(image,CGFloat(Constants.JPEG_QUALITY))
这将被存储和上传。
我读到过可能可以使用“CGImageDestination”,但是我不知道如何在我的情况下使用它们。