PHAsset Location — GPS MetaData, what's wrong?

偶尔善良 提交于 2019-12-10 07:32:49

问题


trying to add location from a UIImage using Phasset:

// image is a variable like so: image: UIImage

var newAsset = PHAssetChangeRequest.creationRequestForAssetFromImage(image)
newAsset.location = CLLocation(latitude: coordinate.latitude, coordinate.longitude)

this code works, apparently -> save a new asset into the photo library with the good coordinate. I can see it in the library itself.

but when I use exif tools and similar, most of the time, GPS dictionnary is empty as if location was not set. (also, I noticed GPS info is not in exif format) so I guess, location information is also somewhere else...

so what's wrong with location property of PHAsset ? how can set properly location ?


回答1:


Photos tracks location metadata it its own database, separately from the EXIF metadata stored in each photo file. When you (as a client of the Photos API) or the user creates/adds a new asset, Photos reads the EXIF location data from the file and sets the location in its database to match. Beyond that, however, the Photos API makes no effort to keep these in sync.

If you want to update the EXIF metadata in the file, you'll need to do that yourself. (Image I/O can help with that — see this answer.) Then, add the whole file, not just a UIImage created from it, to Photos using creationRequestForAssetFromImageAtFileURL: or the new PHAssetCreationRequest stuff in iOS 9.



来源:https://stackoverflow.com/questions/31664822/phasset-location-gps-metadata-whats-wrong

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!