#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 800
#AdditionalJar: metadata-extractor-2.6.2
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private btnExit As Button
Private btnGenerate As Button
Private btnSelectImgPath As Button
Private ImgPath As Label
Private Label1 As Label
Private lstFiles As ListView
Dim OpenFile As DirectoryChooser
Dim ImagePath, ThumbPath As String
Private NativeMe As JavaObject
Dim Lat, Lon As String
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1") 'Load the layout file.
MainForm.Show
NativeMe = Me
Lat=""
Lon=""
End Sub
Sub btnSelectImgPath_MouseClicked (EventData As MouseEvent)
OpenFile.Initialize
OpenFile.InitialDirectory="D:\"
ImagePath=OpenFile.Show(MainForm)
ImagePath=ImagePath & "\"
ImgPath.Text=ImagePath
ListFiles
End Sub
Sub btnGenerate_MouseClicked (EventData As MouseEvent)
' Save the data to a new file
'<a href="images/elde/elde-55.jpg" data-lightbox="Elde" data-title=""><img border="0" src="images/elde/thumbs/elde-55.jpg" width="200" height="133"> </a>
Dim tw As TextWriter
tw.Initialize(File.OpenOutput(ImagePath,"images.html",False))
For c=0 To lstFiles.Items.Size-1
Dim imgFile, Textline As String
imgFile=lstFiles.Items.Get(c)
Log(imgFile)
imgFile=imgFile.SubString(14)
imgFile.Replace("\", "/")
Textline="<a href=" & QUOTE
Textline=Textline & imgFile.Replace(ImagePath, "") & QUOTE
Textline=Textline & " data-lightbox=" & QUOTE & "lb" & QUOTE & " data-title=" & QUOTE & QUOTE
Textline=Textline & "><img border=" & QUOTE & "0" & QUOTE & " src=" & QUOTE & ThumbPath
Textline=Textline & imgFile.Replace(ImagePath, "") & QUOTE
Textline=Textline & " width=" & QUOTE & "200" & QUOTE & "height=" & QUOTE & "133" & QUOTE
Textline=Textline & "> </a>"
Log(Textline)
tw.WriteLine(Textline)
Next
tw.Close
End Sub
Sub btnExit_MouseClicked (EventData As MouseEvent)
MainForm.Close
End Sub
Sub btnGetFiles_MouseClicked (EventData As MouseEvent)
ListFiles
End Sub
Sub ListFiles
Try
For Each FileName As String In File.ListFiles(ImagePath)
Dim FileExtension As String = FileName.Substring2(FileName.length-4, FileName.length)
FileExtension=FileExtension.ToLowerCase
If FileExtension = ".jpg" Then
lstFiles.Items.Add(GetExifDate(FileName))
End If
Next
Catch
Log(LastException)
End Try
lstFiles.Items.Sort(True) 'sort list according to date and time "yyyymmddhhmmss filename"
End Sub
Sub GetExifDate(fn As String) As String
'[Exif SubIFD] Date/Time Original - 2013:09:02 12:54:02
fn = File.Combine(ImagePath, fn)
Dim imgmeta As List = NativeMe.RunMethod("GetImgMeta", Array(fn))
For Each s1 As String In imgmeta
'Log(s1)
If s1.Contains("GPS Latitude") And s1.Contains("°") Then
s1=s1.SubString(21)
s1=s1.Replace("°","")
s1=s1.Replace("'","")
s1=s1.Replace("""","")
Log(s1)
Dim Stamp() As String
Dim Val As Double
Stamp=Regex.Split(" ",s1)
Val=Stamp(0) + (Stamp(1)/60) + (Stamp(2)/3600)
Log(Val)
Return
End If
Next
End Sub
#If JAVA
import com.drew.imaging.*;
import com.drew.metadata.*;
import com.drew.lang.*;
import java.io.*;
import java.util.*;
public static List GetImgMeta(String filename)
{
File file = new File(filename);
List lstMeta = new ArrayList<Object>();
try {
Metadata metadata = ImageMetadataReader.readMetadata(file);
for (Directory directory : metadata.getDirectories()) {
for (Tag tag : directory.getTags()) {
lstMeta.add(tag.toString());
}
if (directory.hasErrors()) {
for (String error : directory.getErrors()) {
System.err.println("ERROR: " + error);
}
}
}
}
catch (ImageProcessingException e) {
// handle exception
lstMeta.add("ImageProcessingException");
}
catch (IOException e) {
// handle exception
lstMeta.add("IOException");
}
return(lstMeta);
}
#End If