PHAsset位置-GPS元数据,怎么了? [英] PHAsset Location -- GPS MetaData, what's wrong?

查看:206
本文介绍了PHAsset位置-GPS元数据,怎么了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用Phasset从UIImage添加位置:

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.

但是当我使用exif工具和类似工具时,大多数情况下,GPS词典是空的,好像未设置位置. (另外,我注意到GPS信息不是exif格式的) 所以我想位置信息也位于其他地方...

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...

那么PHAsset的location属性怎么了? 如何正确设置位置?

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

推荐答案

照片跟踪其自己的数据库中的位置元数据,与存储在每个照片文件中的EXIF元数据分开.当您(作为Photos API的客户端)或用户创建/添加新资产时,Photos将从文件中读取EXIF位置数据,并将其在数据库中的位置设置为匹配.除此之外,Photos API不会努力保持它们的同步.

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.

如果要更新文件中的EXIF元数据 ,则需要自己执行. (图像I/O可以帮助您解决问题-请参见此答案.)然后,添加整个文件,而不仅仅是添加<从中创建的c0>到使用creationRequestForAssetFromImageAtFileURL:或iOS 9中新的PHAssetCreationRequest素材创建的照片.

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.

这篇关于PHAsset位置-GPS元数据,怎么了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆