Hi all,
Continuing on from my first Forum post, where I was copying data from JPG to RAF files, I have now come across a problem with Track files.
To step back one, my aim, as I don't have GPS in my camera, is to sort of 'reverse engineer', adding GPS points and locations to my picture files, and then to create a track file from them.
Using the Geotagging page examples, I seemed to create a KML track file OK, and Geosetter loads it successfully, showing the points (one side question is that from 600 pictures it only created about 300 points - why would that be?)
However, when using the GPX example, I get some [Minor] errors on creating the out.gpx file (Warning: [Minor] Tag 'gpsaltitude' not defined), which I read should be OK?
In Geosetter, when I try to load this out.gpx track file it tells me "The file "out.gpx" doesn't seem to be a valid GPS track file."
My command was exiftool -fileorder gpsdatetime -p gpx.fmt -d %Y-%m-%dT%H:%M:%SZ "E:\New England 2\2016-10-24" > out.gpx
A couple of other errors generated are as follows:
Warning: [Minor] Tag 'gpslatitude' not defined - E:/New England 2/2016-10-24/exiftool(-k).exe
Warning: [Minor] Tag 'imagewidth' not defined - E:/New England 2/2016-10-24/exiftool(-k).exe
Warning: [Minor] Tag 'gpslatitude' not defined - E:/New England 2/2016-10-24/exiftool.exe
Warning: [Minor] Tag 'imagewidth' not defined - E:/New England 2/2016-10-24/exiftool.exe
I have a copy of those executables in the same directory as the JPG's
Thanks for advice
Neil
Hi Neil,
Quote from: neil40 on February 02, 2017, 12:39:30 PM
(one side question is that from 600 pictures it only created about 300 points - why would that be?)
only half the pictures had GPS data?
QuoteHowever, when using the GPX example, I get some [Minor] errors on creating the out.gpx file (Warning: [Minor] Tag 'gpsaltitude' not defined), which I read should be OK?
There you go. And yes, the GPX file will not be valid format if some files are missing GPS. If this is a possibility, you should add this to the command:
-if "$gpslatitude and $gpslongitude"QuoteA couple of other errors generated are as follows:
Warning: [Minor] Tag 'gpslatitude' not defined - E:/New England 2/2016-10-24/exiftool(-k).exe
Warning: [Minor] Tag 'imagewidth' not defined - E:/New England 2/2016-10-24/exiftool(-k).exe
Warning: [Minor] Tag 'gpslatitude' not defined - E:/New England 2/2016-10-24/exiftool.exe
Warning: [Minor] Tag 'imagewidth' not defined - E:/New England 2/2016-10-24/exiftool.exe
You are somehow trying to read exiftool.exe as an input file, which is of course not what you want.
Did you perhaps use "*.*" on the command line?- Phil
Edit: Strike out "*.*" comment -- it would just happen if the .exe was in the image file directory
Ah, OK.
So, I moved the exiftool files out of the directory, and copied exiftool.exe to C:\Windows so it runs from there.
The GPX file is now created and opens in Geosetter.
As for the KML, it's running on the same files, all have GPS data. Commands and results:
exiftool -fileorder gpsdatetime -p gpx.fmt -d %Y-%m-%dT%H:%M:%SZ "E:\New England 2\2016-10-24" > out3.gpx
1 directories scanned
611 image files read
-- Geosetter tells me the track has 412 points
exiftool -p kml.fmt "E:\New England 2\2016-10-24" > out3.kml
1 directories scanned
611 image files read
-- Geosetter tells me this has 322 waypoints
I noticed on https://exiftool.org/geotag.html (https://exiftool.org/geotag.html) it says, at the bottom of the page, below the examples I followed for GPX and KML output:
QuoteThis example print format file is included in the "fmt_files" directory of the full ExifTool distribution
I can't find the full distribution though - the Windows zip only has the exe file in it.
[Edit] - scrub the last part, I found it's in the gz file and 7Zip will open that
Is geosetter right about the count? What if you add the -if condition I mentioned? (although I don't expect this to help if you aren't getting any warnings).
If you were on a Mac or Linux system you could count the Placemarks in the KML file like this:
grep "<Placemark>" out.kml | wc -l
- Phil
Quote from: Phil Harvey on February 02, 2017, 01:28:22 PM
Is geosetter right about the count? What if you add the -if condition I mentioned? (although I don't expect this to help if you aren't getting any warnings).
If you were on a Mac or Linux system you could count the Placemarks in the KML file like this:
grep "<Placemark>" out.kml | wc -l
- Phil
This DOS command does the equivalent
findstr -N "<Placemark>" out3.kml | find /c ":"
and returned 611
Looking at the Track window in Geosetter it shows 322 Waypoints.
In the list of waypoints, I note it is missing Picture names
For example DSCF1307.jpg and 1308 have identical GPS points (take 2 pictures from the same spot, but different zoom)
Only 1307 is in the list of waypoints
Perhaps Geosetter is only showing the unique waypoints, as editing the KML file 1308 is there, as are the other 'missing' waypoints, which the count shows above
It seems my job is done. :)
- Phil
Quote from: Phil Harvey on February 02, 2017, 03:44:29 PM
It seems my job is done. :)
- Phil
Indeed. Thanks once again Phil.
I just loaded the KML into Google Earth and when I look at the points, they are all there.
However, when I click on an image, I just get a white box with the file name in it.
When I check properties of this, it shows the correct path to the file.
Have you seen this before?
[EDIT] I found this Google Earth (GE) forum post, relating to GE 6.1 (I have 7.1 and the same still seems true)
https://productforums.google.com/forum/#!topic/earth/HY-nZaJXKi0;context-place=topicsearchin/earth/exiftool (https://productforums.google.com/forum/#!topic/earth/HY-nZaJXKi0;context-place=topicsearchin/earth/exiftool)
Initially it talks about changing a 'Local File' option which made no difference to me nor the person who posted the comment.
The 'fix' posted at the bottom worked for me in that instead of
<img src='f:/New England 2/2016-10-24/DSCF1307.JPG'I changed it to this within GE
<img src='file:///f:/New England 2/2016-10-24/DSCF1307.jpg'and the image then appeared.
Could I change the FMT file to accommodate this, as it is using a variable for the filename?
You should be able to change kml.fmt line from this
<img src='$directory/$filename'
to this
<img src='file:///$directory/$filename'
Although I don't know why you should need to. It works fine on OS X without the file:///.
- Phil
Thanks Phil,
I adjusted my fmt file to add the file:/// part in, and still it didn't work.
There is a clue in your kml.fmt sample
Quote# 3) Google Earth is picky about the case of the image file extension,
# and may not be able to display the image if an upper-case
# extension is used.
So, I used a bulk file rename program to rename all my pictures from .JPG to .jpg (takes seconds) and bingo, the KML file works.
Now I just need to figure out displaying the images in GE smaller as the fmt file pulls the original size out of the picture.
Almost there!
Right.
And I think that the "file:///" wouldn't have been necessary if you used relative paths as specified in note number 2 of kml.fmt.
You should be able to specify any ImageWidth/Height that you want. For example, if you want half sized:
#[BODY] width='${imagewidth;$_/=2}' height='${imageheight;$_/=2}'>
- Phil
Quote from: Phil Harvey on February 03, 2017, 07:08:55 AM
Right.
And I think that the "file:///" wouldn't have been necessary if you used relative paths as specified in note number 2 of kml.fmt.
You should be able to specify any ImageWidth/Height that you want. For example, if you want half sized:
#[BODY] width='${imagewidth;$_/=2}' height='${imageheight;$_/=2}'>
- Phil
Fantastic.
My modified code, that uses the relative path and image size at a 1/4
#[BODY] <Placemark>
#[BODY] <description><![CDATA[<br/><table><tr><td>
#[BODY] <img src=
'./$filename'#[BODY] width='$
{imagewidth;$_/=4}' height='${imageheight;$_/=4}'>
#[BODY] </td></tr></table>]]></description>
One curiosity. Portrait style pictures that I have rotated manually in Windows, show in Landscape in GE!
Quote from: neil40 on February 03, 2017, 07:41:40 AM
One curiosity. Portrait style pictures that I have rotated manually in Windows, show in Landscape in GE!
It could be that Windows just changed the Orientation tag, and that GE ignores this tag.
BTW, you should use "
$directory/$filename", not "
./$filename" because the latter will work only if the directory you specify on the command line is ".". (Again, use relative directory paths on the command line.)
- Phil
Quote from: Phil Harvey on February 03, 2017, 08:01:58 AM
BTW, you should use "$directory/$filename", not "./$filename" because the latter will work only if the directory you specify on the command line is ".". (Again, use relative directory paths on the command line.)
Ah, sorry, I misinterpreted where I was changing to a relative path! I changed the fmt file instead of the command line. ::)
I'll scout around some GE forums to see what's going on with orientation.
Do you happen to know of a KML reference. I'd like to explore what else I could display on the pop up picture window, such as the co-ordinates and/or location from the data extracted from the picture.
A quick google finds this useful KML reference (https://developers.google.com/kml/documentation/kml_tut).
- Phil
Quote from: Phil Harvey on February 03, 2017, 08:56:09 AM
A quick google finds this useful KML reference (https://developers.google.com/kml/documentation/kml_tut).
- Phil
:) Thanks so much for your help Phil
BTW, I have updated the kml.fmt that will ship with the next ExifTool release to group the files by directory. Attached is the new version in case you are interested in using this feature.
- Phil
Quote from: Phil Harvey on February 03, 2017, 09:10:44 AM
BTW, I have updated the kml.fmt that will ship with the next ExifTool release to group the files by directory. Attached is the new version in case you are interested in using this feature.
- Phil
Thanks for the updated file Phil
Is there a definitive list of variables that exiftool can use with KML?
Sure. The list is here (https://exiftool.org/TagNames/index.html). You may use any of the 20,000+ tags that ExifTool extracts.
- Phil
Quote from: Phil Harvey on February 04, 2017, 09:25:26 PM
Sure. The list is here (https://exiftool.org/TagNames/index.html). You may use any of the 20,000+ tags that ExifTool extracts.
- Phil
Wow! Well I thought that was a bit daunting, but looking at the data stored in the JPG's I want to be able to write
XMP-iptcCore:Location
XMP-photoshop:City
XMP-photoshop:State
XMP-photoshop:Country
So I presume these are $location, $city, $state and $country
My problem is I don't know how to write them into the KML file.
I presume they need to go into the <Snippet/> structure.
I tried
#[BODY] <name>$filename</name>
#[BODY] <name>$location</name>
but while this does extract both to the KML file, when opened in Google Earth, the second line overwrites the first.
I then tried
#[BODY] <name>$filename</name>
#[BODY] <location>$location</location>
but the latter tag is ignored in GE.
Any ideas how I achieve that so I can have
<filename>
<location>
<city>
<state>
<country>
showing with the picture?
Quote from: neil40 on February 06, 2017, 04:05:59 PM
XMP-iptcCore:Location
XMP-photoshop:City
XMP-photoshop:State
XMP-photoshop:Country
So I presume these are $location, $city, $state and $country
That will do, but may also pick up other tags with the same name. If you want to specify them more precisely, use $XMP-iptcCore:Location, $XMP-photoshop:City, $XMP-photoshop:State and $XMP-photoshop:Country.
QuoteAny ideas how I achieve that so I can have
<filename>
<location>
<city>
<state>
<country>
showing with the picture?
That's a KML question. I'm not a KML expert, but I think that the "Using the CDATA Element" section from the reference I found may show a way to do this.
- Phil
Quote from: Phil Harvey on February 07, 2017, 07:21:20 AM
QuoteAny ideas how I achieve that so I can have
<filename>
<location>
<city>
<state>
<country>
showing with the picture?
That's a KML question. I'm not a KML expert, but I think that the "Using the CDATA Element" section from the reference I found may show a way to do this.
- Phil
Phil,
Thanks for the tips on the specific variables.
Looking at the CDATA element closer, I have modified my KML.fmt file as follows, and this works well
#[BODY] <description><![CDATA[<br/><table><tr><td>
#[BODY] <img src='$directory/$filename'
#[BODY] width='${imagewidth;$_/=5}' height='${imageheight;$_/=5}'>
#[BODY] <hr><b>Coordinates:</b> $gpsposition
#[BODY] <br><b>Location:</b> $XMP-iptcCore:Location
#[BODY] <br><b>City:</b> $XMP-photoshop:City
#[BODY] <br><b>State:</b> $XMP-photoshop:State
#[BODY] <br><b>Country:</b> $XMP-photoshop:Country
#[BODY] <br><b>Date taken:</b> $datetimecreated
#[BODY] </td></tr></table>]]></description>
Is there a way to adapt the $datetimecreated variable so that I can display the date and time in a more standard (UK) fashion such as 07-02-2017 10:43:01 (or even 7th February 2017 10:43:01)?
The -d option formats date/time values. See the examples on this page (https://exiftool.org/filename.html) (although these examples show how to format date/time values for file names, the same applies for your purpose). And here is a list of common date format codes (https://exiftool.org/filename.html#codes).
- Phil
Quote from: Phil Harvey on February 07, 2017, 09:54:59 PM
The -d option formats date/time values. See the examples on this page (https://exiftool.org/filename.html) (although these examples show how to format date/time values for file names, the same applies for your purpose). And here is a list of common date format codes (https://exiftool.org/filename.html#codes).
- Phil
Phil, are you implying that I need to write these values to the files beforehand? [Edit] - hmm, don't think you are!
I had noticed you had suggested the modification to the imageheight and imagewidth variables like so ${imagewidth;$_/=5} to reduce the size of image output, so I'd wondered if it was possible to do the same to the datetimecreated variable, to display it differently?
I'm happy looking at the page you directed me to on what I want, it was just a case of how to modify the variable (if I can)
All the examples given are for renaming or moving files.
[Edit] - been trying a few things in the fmt file, but can't figure out how to apply a -d to $datetimecreated !! Just get errors (mostly syntax) :-\
Quote from: neil40 on February 08, 2017, 05:38:34 AM
Phil, are you implying that I need to write these values to the files beforehand?
The
-d option just formats the values of the date/time tags already in the file.
QuoteI had noticed you had suggested the modification to the imageheight and imagewidth variables like so ${imagewidth;$_/=5} to reduce the size of image output, so I'd wondered if it was possible to do the same to the datetimecreated variable, to display it differently?
This is certainly possible, but much more difficult. The
-d is much simpler. Just add the
-d option to your existing command to see what I mean.
QuoteAll the examples given are for renaming or moving files.
Yes. I mentioned this. I gave that reference just so you could see some examples of ways to format date/time tags.
Quote[Edit] - been trying a few things in the fmt file, but can't figure out how to apply a -d to $datetimecreated !! Just get errors (mostly syntax) :-\
I thought it would be simple. Just add something like this to the command you are using to create the KML file:
-d "%Y-%m-%d %H:%M:%S"But you will want to change the formatting codes to give the format you want, and the page I referenced should help with this.
- Phil
Aha, I was overthinking it!
Works perfectly.
Further to your help yesterday suggesting I look at CDATA, I noticed that Geosetter had a GE export tool, which allows custom output of various exif data.
So I created a KMZ file then exported to KML in GE, so I could see the format of the CDATA section which gave me the final clues I need to modify my .fmt file.
Geosetter also allows you to create an icon of the picture you are exporting to GE - is that a feature of exiftool or is it Geosetter? (as Geosetter is using exiftool under the hood)
Hi Neil,
ExifTool doesn't do image manipulation. It may be used to extract an existing thumbnail or preview image, but that's it. I don't know how the icon you mention is generated.
- Phil
Quote from: Phil Harvey on February 08, 2017, 07:29:20 AM
ExifTool doesn't do image manipulation. It may be used to extract an existing thumbnail or preview image, but that's it. I don't know how the icon you mention is generated.
- Phil
I suspected as much, but wanted to check.