How can I write the latitude and longitude in the metadata of a jpg file as shown in the following image
So far I have the following code but it does not work for me, I am using methods that extend the Bitmap class
public static Bitmap WriteCoordinatesToImage(this Bitmap sourceBitmap, double latitude, double longitude)
{
byte[] bLatitude = BitConverter.GetBytes(latitude);
byte[] bLongitude = BitConverter.GetBytes(longitude);
PropertyItem prop = sourceBitmap.PropertyItems[0];
prop.Id = 0x0002;
prop.Type = 5;
prop.Len = bLatitude.Length;
prop.Value = bLongitude;
sourceBitmap.SetPropertyItem(prop);
prop.Id = 0x0004;
prop.Type = 5;
prop.Len = bLatitude.Length;
prop.Value = bLatitude;
sourceBitmap.SetPropertyItem(prop);
return sourceBitmap;
}

You will need to assign the proper EXIF tags. I ran into this a while back and found a solution I liked. Here is the code for it:
There is of course libraries too, but this if all you need is geo this is pretty light weight.
this produces: