开发者

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

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开发者_如何学C).

I am working in ios sdk 3.0 .

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


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜