views:

144

answers:

3

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

+1  A: 

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];
vodkhang
But in that case I won't be able to get that image from standard uiimagepickerviewcontrollersavedphotosalbum and I have to make my my own browser in your case i have seen the photolocations application in apple sample code which does the same thing.
hib
yeah, I know. But seems to be no other ways yet:(
vodkhang
+2  A: 

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.

Ole Begemann
I wish there was a corresponding one with metadata for videos. Maybe 4.2?
Peter DeWeese
Will this :http://stackoverflow.com/questions/1238838/uiimagepickercontroller-and-extracting-exif-data-from-existing-photos work ? or can be rejected ?
hib
A: 

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

GameBit
see the above answer it is possible in 4.1
hib
yeh, but 4.1 is way too young for deployment imo
GameBit
yes, but you can still support it just for those that are on 4.1...
William Denniss