June 12, 2020 Stardate: 73912.5 Tagged as: Ubuntu Exiftool
I use the Mapillary android app for taking “street-level” images, especially while driving. There is a library of CLI-tools available for processing these images if you want/need to do anything customized or above what the mobile app does. It uses the power of one of my favorite tools, Exiftool, and I wanted to dive under the hood to understand Exiftool more. This post is essentially some random information that I want to document for my future use as well as information that the reader can use to build their own photo processing workflow.
You can list all the metadata for a photo:
exiftool -a -s -G file.jpg
!exiftool -a -s -G photo.jpg
Using the -G
flag is useful for seeing groups. One use is if you what to view all tags for a group. For example,
!exiftool -s -G -Composite:all photo.jpg
The -s
flag is useful because it shows the real names of the fields and not the “pretty” or “friendly” name. If you want to show a single tag you can call the name.
!exiftool -s -G -CreateDate photo.jpg
If there are duplicates and any doubt about which tag you are reading/writing, you can define the group.
!exiftool -s -G -EXIF:CreateDate photo.jpg
You can also read multiple tags.
!exiftool -File:FileName -EXIF:CreateDate -Composite:SubSecCreateDate photo.jpg
!exiftool -s -File:FileName -EXIF:CreateDate -Composite:SubSecCreateDate photo.jpg
!exiftool -s -G -File:FileName -EXIF:CreateDate -Composite:SubSecCreateDate photo.jpg
You can also write tags, or overwrite tags. Let’s say I want to create a new metadata tag named “Creator” and add my name to it. I can also write multiple tags at once.
exiftool -Creator="Joe" -Description="This is a sunset taken on lookout hill" photo.jpg
!exiftool -s -G -XMP:all photo.jpg
When you geotag, Exiftool will take the date/time of a photo, find the nearest gps points within a provided log, and then interpolate the position based on the photo’s date/time. If you have a hihg-quality gps receiver and can save a log I think geotagging photo coordinates will improve the location accuracy of the photos.
exiftool -geotag log.gpx *jpg
The above command is telling the tool to perform this position interpolation on all the files mathcing “jpg” in the current directory, using the gps trace “log.gpx” also in the current directory.
From this post it was clarified that the subsecond date/time should be use (if available) for more accurate results.
How to find an appropriate tag? Do a search!
!exiftool -s -G -SubSec* photo.jpg
For this photo it looks like we can use several of composite group tags.
exiftool -geotag log.gpx "-GeoTime<Composite:SubSecCreateDate" *jpg
The tool will update the latitude and longitude positions as well as add a handful of other EXIF and Composite tags.
For example:
!exiftool -s -G1 -GPS:all photo.jpg
If the photos have GPS information, you can create a gps track from a series of photos. This is as simple as:
exiftool -p ./gpx.fmt *jpg > phototrace.gpx
The above command is telling the tool to go through all files matching “*jpg” in the current directory and pull out the gps data for each one. Then write that data in the output file “phototrace.gpx” using the format “gpx.fmt”. The format is completely customizable and is just a template for how to parse the data. The format files are located here or you can make your own. Note that in this example the location of the file is in the current directory.
If you want to export a Google Earth friendy kml file:
exiftool -p ./kml.fmt *jpg > phototrace.kml
On an Android the photos taken from the Mapillary app are stored in the app data directory. Most likely you are storing the photos on an external SD Card, if so the storage location is:
SAMSUNG Android/Card/Android/data/app.mapillary/files/CAMERA2_0/<dirs>/
Otherwise the storage location is:
SAMSUNG Android/Phone/Android/data/app.mapillary/files/CAMERA2_0/<dirs>/
Another interesting note is that a gpx file is also created and stored in the corresponding directory. Photos are named by Mapillary in this format:
2020_06_06_14_06_41_856_+0530.jpg
which translates to
YYY\_MM\_DD\_HH\_MM\_SS\_xxx\_UTCOffset
I’m not sure what “xxx” is. I thought it was the subseconds but it doesn’t look like it. Another theory is that it was the subseconds at time of initial file creation and then the field SubSecTime
is at the time the metadata was created. The difference is the processing delay or time it took to write the file. At least that is my theory…
!exiftool -s -G \
-File:FileName -EXIF:CreateDate -EXIF:DateTimeOriginal \
-EXIF:SubSecTime -EXIF:SubSecTimeOriginal -Composite:SubSecCreateDate \
photo.jpg
%load_ext version_information
%version_information
This is an automated list of software versions used during the writing of this article.
Software Version
OS Ubuntu 20.04 LTS
Exiftool 11.88