basically I am using the example code from http://docs.xamarin.com/ios/recipes/Media/Video_and_Photos/Save_Photo_to_Album_with_Metadata
when I would take a photo and check the files exif data (either through http://exifdata.com/ or Exif-Wizard on the Device), I noticed the exif data did not contain GPS information, so I manually collect the location information, format it, and add it to a dictionary and include that in the meta dictionaries as seen below.
btnCamera.Clicked += delegate {
TweetStation.Camera.TakePicture (this, (obj) => {
var photo = obj.ValueForKey (new NSString ("UIImagePickerControllerOriginalImage")) as UIImage;
var meta = obj.ValueForKey (new NSString ("UIImagePickerControllerMediaMetadata")) as NSMutableDictionary;
var gpsDict = new NSMutableDictionary ();
...
gpsDict.SetValueForKey (NSObject.FromObject (GpsLong), new NSString ("GPSLongitude"));
gpsDict.SetValueForKey (NSObject.FromObject (GpsLongRef), new NSString ("GPSLongitudeRef"));
gpsDict.SetValueForKey (NSObject.FromObject (GpsLat), new NSString ("GPSLatitude"));
gpsDict.SetValueForKey (NSObject.FromObject (GpsLatRef), new NSString ("GPSLatitudeRef"));
gpsDict.SetValueForKey (NSObject.FromObject (DateTime.UtcNow.ToString ("HH:MM:ss.ff")), new NSString ("GPSTimeStamp"));
meta.SetValueForKey (gpsDict, new NSString ("{GPS}"));
Console.WriteLine (meta.Description);
ALAssetsLibrary library = new ALAssetsLibrary ();
library.WriteImageToSavedPhotosAlbum (photo.CGImage, meta, (assetUrl, error) => {
if (error != null) {
Console.WriteLine ("error: "+ error.ToString ());
}
):
Problem is, this doesn’t seem to work, if (error != null) {Console.WriteLine (error.ToString ());} doesn’t print any problems and in the Console.WriteLine (meta.Description); the output is as follows
{
DPIHeight = 72;
DPIWidth = 72;
Orientation = 6;
"{Exif}" = {
ApertureValue = "2.970853654340484";
BrightnessValue = "1.87496238139573";
ColorSpace = 1;
DateTimeDigitized = "2012:08:02 17:12:42";
DateTimeOriginal = "2012:08:02 17:12:42";
ExposureMode = 0;
ExposureProgram = 2;
ExposureTime = "0.06666666666666667";
FNumber = "2.8";
Flash = 24;
FocalLength = "3.85";
ISOSpeedRatings = (
160
);
MeteringMode = 5;
PixelXDimension = 2592;
PixelYDimension = 1936;
SceneType = 1;
SensingMethod = 2;
Sharpness = 2;
ShutterSpeedValue = "3.911199862602335";
SubjectArea = (
1295,
967,
699,
696
);
WhiteBalance = 0;
};
"{GPS}" = {
GPSLatitude = "30.35974270979283";
GPSLatitudeRef = N;
GPSLongitude = "91.13930279830274";
GPSLongitudeRef = W;
GPSTimeStamp = "22:08:44.66";
};
"{TIFF}" = {
DateTime = "2012:08:02 17:12:42";
Make = Apple;
Model = "iPhone 4";
Software = "5.0.1";
XResolution = 72;
YResolution = 72;
};
}
showing the gps data.
So, I am curious as to what I am doing wrong, I am very new to monotouch (mac as well) so you’ll forgive the general WTF’ery please.
Also, just FYI, to prevent typos those strings are exposed as the
CGImagePropertiesenum in MonoTouch