B4J Tutorial Get EXIF GPS information and show images in google maps

My Aim: Extract the gps information from all images in a directory and generate a html file to view in a browser showing all images in google maps at the coordinates they were taken.


As a follow-up to my question in this thread: Link and the code from canalrun hier: Link, I will post my whole project for those who are interested.

You will need the latest version of metadata-extractor (Link). Version 2.6.2 does not seem to work for the newer Nikon cameras. Extract the two files and put them in your other libraries directory.

To use the program I would recommend the following:

1. Create a directory eg. Img2HTM (change line 42 if you want another directory)
2. Extract the GM_Utils.zip so that it is a subdirectory of 1 above
3. Create a sub directory in 1 eg. images

Now you will have eg.:

d:\Img2HTM
d:\Img2HTM\GM_Utils
d:\Img2HTM\images

Now put your images in the images subdirectory, the ones including gps info would be a good idea.

Run the B4J app and tell it where to find your images. Generate the html and view it in your browser.

If all has gone well, you should see something like this. Clicking on an icon will open the image.

gm.PNG


gm-open.PNG



Have fun.
 

Attachments

  • GM_Utils.zip
    90.4 KB · Views: 486
  • B4J.zip
    4.2 KB · Views: 485

miker2069

Active Member
Licensed User
Longtime User
Very nice! Took a few minutes to get it up and running and works very well. Just added a line or two to handle the situation where it can't pull long/lat for a pic (just skips it). I tested it on some paris pics from a few years back and worked very nicely. Well Done!
parispicstest-min2.jpg
 

TomDuncan

Active Member
Licensed User
Longtime User
Very nice indeed.
I had to add a check for strings not matching.
around line 90

B4X:
        Try
            p(0)=p(0).SubString(p(0).LastIndexOf("\")+1)
            Lat=p(1)
            Lon=p(2)
        Catch
            Log(LastException)
        End Try

Tom
 

wl

Well-Known Member
Licensed User
Longtime User
very nice,

I have one issue though: it seems that only landscape pictures are displayed correctly, portrait pictures seem to be displayed in a rotated way ?

Thanks
 

Smee

Well-Known Member
Licensed User
Longtime User
I have run the program but I am getting an error on line 137
the line is
B4X:
Dim imgmeta As List = NativeMe.RunMethod("GetImgMeta", Array(fn))

the error is;
java.lang.ClassCastException: class java.lang.NoClassDefFoundError cannot be cast to class java.lang.Exception (java.lang.NoClassDefFoundError and java.lang.Exception are in module java.base of loader 'bootstrap')

the log on line 136 is "F:\Basic4Android\Img2HTM\images\1105.JPG"


F:\Basic4Android\Img2HTM\images\1105.JPG


UPDATE:
This is the exception that is logged at line 126 ( after the first image is read)
(Exception) java.lang.Exception: java.lang.reflect.InvocationTargetException
 
Last edited:

Mark Read

Well-Known Member
Licensed User
Longtime User
Hello Smee, this is an old thread. The metadata-extractor has been updated (version 2.11.0 is the newest I think). Try downloading this. Also there are problems with photos taken with Nikon cameras or if there is no gps data in the file. Have a look at the Exif data (Irfanview fro example) and check that the test in line 126 is still valid.
Hope this helps a little.
 

Smee

Well-Known Member
Licensed User
Longtime User
Hello Smee, this is an old thread. The metadata-extractor has been updated (version 2.11.0 is the newest I think). Try downloading this. Also there are problems with photos taken with Nikon cameras or if there is no gps data in the file. Have a look at the Exif data (Irfanview fro example) and check that the test in line 126 is still valid.
Hope this helps a little.

Hi Mark
I was just about to pose the question in a new thread when I saw you had answered so thank you for that
The problem was not the Metadata extractor but the other Add Lib was remarked out, I did some searching and included the file xmpcore-5.1.3 in and that fixed most of the problems

There were a couple of other little tweaks needed but it is running now
I know zero Java so I have just been winging it
I noticed that this line has also been remarked out in the HTML build
Wpcluster = true;
Is this important?

I say it is running but The image page is listed for development purposes by google, I assume I need to get an API key to fix this?

I was able to bypass the errors with no data with this addition

B4X:
        entry=lstFiles.Items.Get(c)
        If entry<>"" Then


Many thanks for your help and thanks for making this code available

1601883051690.png
1601883051690.png
 
Top