I am having major issues trying to save a photo to camera roll with geotag info on iOS4.1. I am using following ALAssetsLibrary API:
- (void)writeImageDataToSavedPhotosAlbum:(NSData *)imageData
metadata:(NSDictionary *)metadata
completionBlock:(ALAssetsLibraryWriteImageCompletionBlock)completionBlock
I have the GPS coordinates that i wish to save with the photo as an input. Unfortunately, there is no documentation or sample code that describes how to form the metadata NSDictionary that encapsulates the GPS coordinates. Can somebody post a sample code that is known to work ?
I have also tried using iPhone Exif library to save geo info in imageData rather than using metadata, but unfortunately iPhone Exif library is crashing. Any help is greatly appreciated.
Best Answer
Here is code to copy all available information from a CLLocation object into the proper format for a GPS metadata dictionary:
Assign the dictionary returned by this method as the value for the
kCGImagePropertyGPSDictionary
key in the metadata dictionary you pass towriteImageDataToSavedPhotosAlbum:metadata:completionBlock:
orCGImageDestinationAddImage()
.