How to write/get latitude longitude with image in uiimagepickercontroller?

ぃ、小莉子 提交于 2019-12-04 08:34:12

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.

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];
lari

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.

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

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