Results 1 to 9 of 9
  1. #1
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280

    Getting GPS data from JPG file

    I now have some photos (.jpg) with GPS data in them as can be seen using Windows file properties.
    However, I can't seem to find this data in the EXIF list.

    I normally use GetDetailsOf in my database code, with an Offset to the appropriate item, e.g. 260 for F-Stop.


    Can't seem to find an item for Latitude, Longitude and Altitude.

    It must be in there somewhere because searching indicated that GPS data is stored in EXIF - quote from AI
    "Geolocation. The Exif format has standard tags for location information. As of 2014, many cameras and mobile phones have a built-in GPS receiver that stores the location information in the Exif header when a picture is taken."

    Does anyone know which EXIF items these are, or if GPS data has to be extracted from the file in some other way, and if so, how - example code would be ideal.

    Thanks

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 11 Access 2021
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    June7,

    Thanks for the link. I'll plough through it. Does not look as if it is going to be as simple as extracting other EXIF data.

  4. #4
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    I have read the link and the easiest way seems to be to use WIA.ImageFile

    I created some code in an Excel spreadsheet, which I am sure will work in my database :- as follows
    Code:
    Sub Test()
        On Error GoTo ErrorHandler
        
        With CreateObject("WIA.ImageFile")
            .LoadFile "path to file"
            With .Properties("GpsLatitude").Value
                MsgBox .Item(1).Value + .Item(2).Value / 60 + .Item(3).Value / 3600
            End With
            With .Properties("GpsLongitude").Value
                MsgBox .Item(1).Value + .Item(2).Value / 60 + .Item(3).Value / 3600
            End With
            'With .Properties("GpsAltitude").Value
            '    MsgBox .Item(1).Value
            'End With
        End With
        
        Exit Sub
        
    ErrorHandler:
        MsgBox "No GPS Data"
    End Sub
    Only thing was the Altitude reference did not work, so will have to see if I can find the correct name to get GPS Altitude.

  5. #5
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    The correct way to get Altitude is :-
    Code:
            With .Properties("GpsAltitude").Value
                MsgBox .Value
            End With
    Now just got to figure out how to get the GPS data from video files. WIA.Image won't do this, but have seen a video showing a tool that might do this for all files.

    Extract GPS Metadata from .MP4 and create .GPX using Exiftool - YouTube

  6. #6
    moke123's Avatar
    moke123 is online now Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  7. #7
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    Moke, thanks for the reply. I think this app also only works for jpegs.

    I've solved that one now and have incorporated the GPS from jpegs into my photo application - using the WIA.ImageFile method.
    Its quick and very easy.

    I'll probably ignore GPS from video files unless someone knows of a similar method to WIA for MP4's.
    I could probably get ExifTool to work, but its a bit too over-engineered for my purposes.

  8. #8
    Miles R is offline Competent Performer
    Windows 11 Office 365
    Join Date
    Mar 2019
    Posts
    280
    In case anyone is interested, this is the code I finally used :-
    Code:
                    ' Get GPS Data if there is any.
                    gpsstr = ""
                    
                    On Error GoTo NoGPS
                    
                    With CreateObject("WIA.ImageFile")
                        .LoadFile gconMyPictures & gshlFolder & "\" & strFileName
                        With .Properties("GpsLatitude").Value
                            gpsstr = " GPS Coordinates" & vbCrLf & " Latitude  = " & Right(" " & .Item(1), 2) & Chr$(176) & " " & Right(" " & Int(.Item(2)), 2) & _
                                "' " & Right(" " & Int((.Item(2) - Int(.Item(2))) * 60), 2) & """ " & IIf(.Item(1) >= 0, "North", "South")
                        End With
                        With .Properties("GpsLongitude").Value
                            gpsstr = gpsstr & vbCrLf & " Longitude = " & Right(" " & .Item(1), 2) & Chr$(176) & " " & Right(" " & Int(.Item(2)), 2) & _
                                "' " & Right(" " & Int((.Item(2) - Int(.Item(2))) * 60), 2) & """ " & IIf(.Item(1) >= 0, "East", "West")
                        End With
                        With .Properties("GpsAltitude").Value
                            gpsstr = gpsstr & vbCrLf & " Altitude  = " & .Value & " metres " & IIf(.Value >= 0, "above sea level", "below sea level")
                        End With
                    End With
                    [Form_Main Form].lblGPS.Caption = gpsstr
                    [Form_Main Form].lblGPS.Visible = True
    NoGPS:
    Which produces a display such as :-

    Click image for larger version. 

Name:	Screenshot 2025-08-18 144148.png 
Views:	16 
Size:	11.7 KB 
ID:	53188
    Last edited by Miles R; 08-18-2025 at 07:44 AM. Reason: diagram disappeared

  9. #9
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,550
    Thank you for posting your solution.

    So many others do not.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 8
    Last Post: 03-17-2025, 06:08 PM
  2. GPS Tracking Data
    By navex in forum Access
    Replies: 2
    Last Post: 07-15-2017, 07:35 PM
  3. Replies: 14
    Last Post: 03-05-2014, 10:54 AM
  4. Acquire Blue Tooth GPS data via comm port
    By Galmala in forum Import/Export Data
    Replies: 1
    Last Post: 04-18-2013, 01:49 PM
  5. Replies: 1
    Last Post: 09-27-2010, 10:10 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums