Saving GPS data to jpeg

mkvidyashankar

Active Member
Licensed User
Longtime User
I am trying to save GPS coordinates but not successful
lat and lon are GPS coordinates extracted from GPS and it is working
but trying to save in JPEG using the below code

Sub clickbutton_Click
camera1.SceneMode=scene.ToUpperCase
camera1.ColourEffect=effect.ToUpperCase
camera1.GPSLatitude= lat
camera1.GPSLongitude=lon
camera1.TakePicture

End Sub
 

mkvidyashankar

Active Member
Licensed User
Longtime User
I tried this but not able to save the information

Sub camera1_PictureTaken (Data() As Byte)

Dim out As OutputStream
out = File.OpenOutput(File.DirRootExternal, "vidcam/test.jpg", False)
out.WriteBytes(data, 0, data.Length)
camera1.StartPreview
out.Close
exif.Initialize(File.DirRootExternal, "vidcam/test.jpg")
exif.setAttribute(exif.TAG_GPS_LATITUDE,lat)
exif.setAttribute(exif.TAG_GPS_LONGITUDE,lon)

exif.setAttribute(exif.TAG_DATETIME,now())

ToastMessageShow("Image saved: " & File.Combine(File.DirRootExternal, "vidcam/Test.jpg"), True)

End Sub
 

Attachments

  • test6.jpg
    test6.jpg
    84.6 KB · Views: 314
Last edited:
Upvote 0

mkvidyashankar

Active Member
Licensed User
Longtime User
Hi agraham

I tried. Some values are storing. but both values are same i.e. lat and lon. And that is also not correct. Is there any specific format to save the value.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
The data needs to be in the correct format as noted in the library comments. From https://docs.google.com/viewer?url=http://www.exif.org/Exif2-2.PDF

The latitude is expressed as three RATIONAL values giving the degrees, minutes, and seconds, respectively. If latitude is expressed as degrees, minutes and seconds, a typical format would be dd/1,mm/1,ss/1. When degrees and minutes are used and, for example, fractions of minutes are given up to two decimal places, the format would be dd/1,mmmm/100,0/1.
 
Upvote 0

mkvidyashankar

Active Member
Licensed User
Longtime User
Thanks for reply, i got it using this sub


Sub ctostring(ang As Float) As String
Dim deg As Int
Dim mint As Int
Dim sec As Double
Dim minf As Float
Dim clus As String
deg = ang
minf= (ang-deg)*60
mint= (ang-deg)*60
sec =(minf-mint)*60
clus = deg & "/1," & mint & "/1," & sec &"/1"
Return(clus)

End Sub
 
Upvote 0
Top