如何在 uiimagepickercontroller 中写入/获取图像的纬度经度?

发布于 2024-09-24 19:00:46 字数 349 浏览 1 评论 0原文

目前我正在“保存的相册”中使用以下方法保存图像。

UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

现在我想将当前的纬度和经度与该图像关联起来。

我怎样才能这样做呢?

我可以使用它的 mediaInfo 字典(元数据)吗?

我正在 ios sdk 3.0 工作。

请告诉我如何在 UIImageViewPickerController 中使用图像获取/设置地理数据

Currently I am saving and image with the following method in "saved photos album".

UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);

Now I want to associate the current latitude and longitude with that image.

How can I do so ?

Can I do with its mediaInfo dictionary (metadata).

I am working in ios sdk 3.0 .

Please tell me How to get /set geo data with an image in UIImageViewPickerController

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

巴黎夜雨 2024-10-01 19:00:46

据我所知,iOS 4.0 及更低版本不支持此功能。

从 iOS 4.1 开始,您可以使用 -[ALAssetsLibrary writeImageToSavedPhotosAlbum:metadata:completionBlock:] 来保存带有元数据的图像(未经测试,但我认为这应该可行)。不过,我不知道如何格式化 metadata 字典。

您应该尝试从资产库中读取一些包含地理数据的现有图像,以检查字典的格式必须如何。

AFAIK this is not supported in iOS 4.0 and lower.

As of iOS 4.1, you can use -[ALAssetsLibrary writeImageToSavedPhotosAlbum:metadata:completionBlock:] to save images with metadata (untested but I assume this should work). I do not know how to format the metadata dictionary, though.

You should try to read some existing images that contain geodata from the assets library to check how the dictionary must be formatted.

唱一曲作罢 2024-10-01 19:00:46

恐怕您无法使用 UIImageWriteToSavedPhotosAlbum 进行操作。

但是,您可以使用另一种方法保存到iPhone文件系统中(但不能保存到“保存的相册”中)。然后将其元数据保存在另一个文本文件中,并使用图像路径:

对于 PNG:

[UIImagePNGRepresentation(image) writeToFile: uniquePath atomically: YES];

对于 JPG:

[UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES];

I am afraid that there is no way for you to do using UIImageWriteToSavedPhotosAlbum.

However, you can use another method to save into iphone file system (but not in "saved photos album"). Then you save its metadata in another text file, going with the image path:

For PNG:

[UIImagePNGRepresentation(image) writeToFile: uniquePath atomically: YES];

For JPG:

[UIImageJPEGRepresentation(image, 1.0) writeToFile:jpgPath atomically:YES];
坏尐絯℡ 2024-10-01 19:00:46

如果您从相机获取图像,则应该从 CLLocationManager 获取位置。如果您从库中选择图像,则可以使用 ALAssertsLibrary 读取位置坐标:

iPhone获取 UIImagePickerController Lat/Lng

获得位置后,您应该能够使用 exif 库将数据与图像一起保存。

If you are getting the image from Camera, you should get the location from CLLocationManager. If you pick the image from library, you can read the location coordinates using ALAssertsLibrary:

iPhone Get UIImagePickerController Lat/Lng

After you have the location, you should be able to use exif library to save the data with the image.

动听の歌 2024-10-01 19:00:46

您无法从来自 uiimagepickercontroller 的图像中获取纬度和经度。看来苹果剥离了 exif 标签(我猜是出于隐私原因)。

you cant get latitude and longitude from image what comes from uiimagepickercontroller. It seems apple striping exif tags (i guess for privacy reasons).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文