ExifTool Forum

ExifTool => Developers => Topic started by: Ian on October 01, 2010, 07:29:21 AM

Title: VB.net Examples
Post by: Ian on October 01, 2010, 07:29:21 AM
Hi.

I have looked at the example of the Exiftool Use below and the preview work in VS2008 Express Edition.

I'm new to using VB and I'm struggling with Trying to get out GPS data to 2 variable's LAT and LONG.  I want to convert my Cameras (TZ10 built in GPS) to Ordnance survey National Grid form.

Can some some point me in the correct direction for get the Exif data  in  variables ?

Thanks in anticipation

Ian

===TAKEN FROM https://exiftool.org/ BASIC VB EXAMMPLE=================
Dim ExifTool As New Process

ExifTool.StartInfo.FileName = "C:\WINDOWS\exiftool.exe"
ExifTool.StartInfo.Arguments = "-b -previewimage" + " " + Chr(34) + FileName + Chr(34)
ExifTool.StartInfo.UseShellExecute = False
ExifTool.StartInfo.RedirectStandardOutput = True
ExifTool.StartInfo.CreateNoWindow = True
ExifTool.Start()

pbx.Image = New Bitmap(ExifTool.StandardOutput.BaseStream).GetThumbnailImage(120, 80, Nothing, Nothing)

ExifTool.Close()
========================================================================================
Title: Re: VB.net Examples
Post by: Phil Harvey on October 01, 2010, 07:45:20 AM
Hi Ian,

It would be good if someone with VB experience could give you an example, but even not knowing VB the sample you posted could be used to extract lat and lon easily by replacing "-b -previewimage" with "-S -s -n -gpslatitute -gpslongitude", then when you do something like this:

var = ExifTool.StandardOutput.BaseStream

then var should contain latitude and longitude strings ending with a newline.  All you have to do then is separate the values and convert to numbers.

- Phil
Title: Re: VB.net Examples
Post by: Ian on October 03, 2010, 04:17:01 AM
Hi Phil.

Thanks fro your pointer. Did a little digging and this is what I came up with.  I placed the Sub in a Module, Then I have a sub that Pull the coords. The Message box is just for testing to let me know if photos have no data.

I pass the sub the file name of the Photo.

If anybody else is looking at OSGB36 Coords their is a free lib @ http://www.qgsl.com/?product=gridinquest (http://www.qgsl.com/?product=gridinquest)


As a vb newbie this might be dirty code but at the min it works for me.

Thanks for your help.









Module GPSExifData

    Public Latitude As Double = Nothing
    Public Longtitude As Double = Nothing
    Public Osgb36_02_Easting As Double
    Public Osgb36_02_Northing As Double
    Dim ValidGeographicalCoords As Boolean = False

    Public Sub ReadCoords(ByVal FileName As String)

        Dim TextOut As String
        Dim ExifData() As String = Nothing
        Dim ExifTool As New Process

        ExifTool.StartInfo.FileName = "c:\exiftool.exe" ' Make sure you place this in a convenient location.
        ExifTool.StartInfo.Arguments = "-S -s -n -gpsposition" + " " + Chr(34) + FileName + Chr(34)
        ExifTool.StartInfo.UseShellExecute = False
        ExifTool.StartInfo.RedirectStandardOutput = True
        ExifTool.StartInfo.CreateNoWindow = True
        ExifTool.Start()
        TextOut = ExifTool.StandardOutput.ReadToEnd.ToString
        ExifTool.Close()

        'Trap Photo if No Data
        If TextOut = Nothing Then
            MsgBox("No GPS Info in Exif Data", MsgBoxStyle.Information, "GPS Data not available")
            ValidGeographicalCoords = False
        Else
            ExifData = Split(TextOut, " ") 'split the return at space into Exifdata(0) = Lat ExitData(1)=Long
            Latitude = CDbl(ExifData(0).ToString.Trim)
            Longtitude = CDbl(ExifData(1).ToString.Trim)
            ValidGeographicalCoords = True
        End If

    End Sub



End Module