GPS Image Details
WSH (Windows Scripting Host) VBScript to get the GPS EXIF (Exchangeable image file format) information from images that have been taken using a camera with GPS function.
Create a new text file in the folder containing the images, you can name it gps_image_data.vbs.
Copy the following code into it, Save, Close.
Double click on the new file in Windows Explorer to run it.
'PAULGRANT.CA 2011
Option Explicit
'On Error Resume Next
Const ForWriting = 2
Const FileCreate = True
Const TristateTrue = -1 'Unicode
Const SecondsToWait = 10
Const YesNo = 4
Const IconQuestion = 32
Dim WshShell, iCode, sCurrentFolderName, sOutputFileName
Dim oFS, oFolder, oTS, oImg, oFile
Dim iPos, sExt, sString
Set WshShell = WScript.CreateObject("WScript.Shell")
iCode = WshShell.Popup("Continue?", SecondsToWait, "Run This Script?", YesNo + IconQuestion)
If (iCode <> 6) Then
WScript.Quit 1
End If
sCurrentFolderName = WshShell.CurrentDirectory
sOutputFileName = sCurrentFolderName & "\output.txt"
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFS.GetFolder(sCurrentFolderName)
Set oTS = oFS.OpenTextFile(sOutputFileName, ForWriting, FileCreate, TristateTrue)
Set oImg = CreateObject("WIA.ImageFile")
For Each oFile In oFolder.Files
iPos = InStrRev(oFile.Name, ".")
sExt = Mid(oFile.Name, iPos)
If (LCase(sExt) = ".jpg") Then
sString = DoImage(oFile.Name)
If (sString <> "") Then
oTS.WriteLine sString
End If
End If
Next
oTS.Close
WScript.Echo "Done"
'FUNCTIONS
Function DoImage(sFileName)
Dim i, j, v, s, sOutput, sPropertyName
sOutput = ""
oImg.LoadFile sFileName
For i = 1 to oImg.Properties.Count
sPropertyName = oImg.Properties(i).Name
If InStr(sPropertyName, "Gps") > 0 Then
s = sPropertyName & "(" & oImg.Properties(i).PropertyID & ") = "
If oImg.Properties(i).IsVector Then
s = s & "[vector]"
Set v = oImg.Properties(i).Value
If sPropertyName = "GpsLatitude" Then
s = s & FormatCoords(v, oImg.Properties("GpsLatitudeRef").Value)
ElseIf sPropertyName = "GpsLongitude" Then
s = s & FormatCoords(v, oImg.Properties("GpsLongitudeRef").Value)
Else
For j = 1 To v.Count
s = s & v(j) & " "
Next
End If
Else
s = s & oImg.Properties(i).Value
End If
sOutput = sOutput & s & vbCrLf
End If
Next
DoImage = sOutput
End Function
Function FormatCoords(v,sRef)
'On Error Resume Next
Dim sCoords
sCoords = v(1) & Chr(176) & v(2) & Chr(39) & v(3) & Chr(34) & sRef
FormatCoords = sCoords
End Function
'End.
GPS Latitude and Longitude Image EXIF Details
Creates a list of image names along with Latitude, Longitude separated by tab, for each image in a folder.
With the value of HTML_OUTPUT set to True, it will produce an HTML file containing thumbnails of the images and links to google maps.
Create a new text file called gps_image_data_latlong.vbs, in the same folder as your images.
Copy this code into it, Save, Close.
Double click the file in Windows Explorer to run it.
'PAULGRANT.CA 2011
Option Explicit
'On Error Resume Next
Const ForWriting = 2
Const FileCreate = True
Const TristateTrue = -1 'Unicode
Const SecondsToWait = 10
Const YesNo = 4
Const IconQuestion = 32
Const HTML_OUTPUT = True
Dim WshShell, iCode, sCurrentFolderName, sOutputFileName
Dim oFS, oFolder, oTS, oImg, oFile
Dim iPos, sExt, sString
Set WshShell = WScript.CreateObject("WScript.Shell")
iCode = WshShell.Popup("Continue?", SecondsToWait, "Run This Script?", YesNo + IconQuestion)
If (iCode <> 6) Then
WScript.Quit 1
End If
sCurrentFolderName = WshShell.CurrentDirectory
If HTML_OUTPUT = False Then
sOutputFileName = sCurrentFolderName & "\output2.txt"
Else
sOutputFileName = sCurrentFolderName & "\output2.html"
End If
Set oFS = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFS.GetFolder(sCurrentFolderName)
Set oTS = oFS.OpenTextFile(sOutputFileName, ForWriting, FileCreate, TristateTrue)
Set oImg = CreateObject("WIA.ImageFile")
For Each oFile In oFolder.Files
iPos = InStrRev(oFile.Name, ".")
sExt = Mid(oFile.Name, iPos)
If (LCase(sExt) = ".jpg") Then
sString = DoImage(oFile.Name)
If (sString <> "") Then
oTS.WriteLine sString
End If
End If
Next
oTS.Close
WScript.Echo "Done"
'FUNCTIONS
Function DoImage(sFileName)
On Error Resume Next
Dim vLatitude, vLongitude
Dim sLatitude, sLongitude, sLatitudeRef, sLongitudeRef
oImg.LoadFile sFileName
Set vLatitude = oImg.Properties("GpsLatitude").Value
Set vLongitude = oImg.Properties("GpsLongitude").Value
If IsEmpty(vLatitude) OR IsEmpty(vLongitude) Then
DoImage = ""
Exit Function
End If
sLatitudeRef = oImg.Properties("GpsLatitudeRef").Value
sLongitudeRef = oImg.Properties("GpsLongitudeRef").Value
sLatitude = FormatCoords(vLatitude, sLatitudeRef)
sLongitude = FormatCoords(vLongitude, sLongitudeRef)
If (sLatitude = "") OR (sLongitude = "") Then
DoImage = ""
Exit Function
End If
If HTML_OUTPUT = False Then
DoImage = sFileName & vbTab & sLatitude & "," & sLongitude
Else
DoImage = "![]()
" & vbCrLf _
& "" & sLatitude & "," & sLongitude & "
"
End If
End Function
Function FormatCoords(v, sRef)
'On Error Resume Next
Dim sCoords
sCoords = v(1) & Chr(176) & v(2) & Chr(39) & v(3) & Chr(34) & sRef
FormatCoords = sCoords
End Function
'End.