Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 688

EXIF from jpg and link to google maps - "Convert" vbs to asp classic page

$
0
0
Hello, sorry for my bad English.
I have create an asp classic page with a list of photos (jpg), i have to put a link for every image pointing to google maps.
So i need to extract exif info from the file jpg an create the link.

Looking online:

http://paulgrant.ca/code_image_details_gps.html

I found this code, do exactly what i need, but it’s a file .vbs :sick:

This is all the code:

Code:

'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 = True Then
        sOutputFileName                        = sCurrentFolderName & "\output2.txt"
Else
        sOutputFileName                        = sCurrentFolderName & "\output2.html"
End If

Set oFS                        = WScript.CreateObject("Scripting.FileSystemObject")
Set oFolder                = oFS.GetFolder(sCurrentFolderName)
Set oTS                        = oFS.OpenTextFile(sOutputFileName, ForWriting, FileCreate, TristateTrue)
Set oImg                = WScript.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 = "<a href=""" & sFileName & """ target=""_blank""><img border=""0"" src=""" & sFileName & """ width=""100"" height=""75""></a><br>" & vbCrLf _
                & "<a href=""http://maps.google.com/?q=" & Escape(sLatitude & "," & sLongitude) & """ target=""_blank"" style=""text-decoration:none;color:black;"">" & sLatitude & "," & sLongitude & "</a><br><br>"
        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.

If you click on it, it generate a txt in the same folder with the link with the coordinate to google maps.

How I can “convert” it in an asp page? Instead generate txt file, send a “response.write” with the link to my asp page?

...sorry for my REQUEST and thanks to those who will help me.:o

Viewing all articles
Browse latest Browse all 688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>