Trying to stamp images with exiftool

Started by davidcalvin, August 01, 2013, 09:21:51 PM

Previous topic - Next topic

davidcalvin


Hello,

I am relatively new to exiftool. I need to stamp a series of images with GPS locations. I am following the directions that invole issuing:

xiftool -r -p gpx.fmt  IMG_0019.JPG > out.gpx

IMG_0019.JPG has GPS data. I am assuming that the above command will create a track file for me. I then use the outputted out.gpx file to stamp a non tagged image like this:

exiftool -p -geotag out.gpx /Users/me/Pictures/LBReplicateCache/

And I get:

    1 directories scanned
    0 image files updated
    5 image files unchanged

I have also tried the command this way:

exiftool -geotag=out.gpx /Users/me/Pictures/LBReplicateCache/

With the same result. The .gpx file seems to have valid lat and longitude data in it. I am wondering if there is an issue with the file. Here is what the first command created:

<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.0"
creator="ExifTool 9.33"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<trk>
<number>1</number>
<trkseg>
<trkpt lat="25.0361666666667" lon="121.519">
  <ele>16.27441406</ele>
</trkpt>
</trkseg>
</trk>
</gpx>

Does that look valid? Man.. I am totally stuck. Any help would be thoroughly appreciated. I tried doing a search on the forum and came up empty.

Thanks,

David

Phil Harvey

Hi David,

If you read the documentation in out.gpx, the correct command is:

exiftool -p gpx.fmt -d %Y-%m-%dT%H:%M:%SZ FILE [...] > out.gpx

The problem is that you weren't formatting the timestamps correctly.

If it doesn't work after this, it is because the times between the two images are too far apart.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin

Hi Phil,

Thanks for  the response. I will give that a try.

Is it necessary for time  stamps to be involved in order to stamp an image with GPS data?

Thanks,

David

davidcalvin

And, BTW, I did try that syntax. I got the impression that the timestamp was not necessary due to this from the docs:


This example assumes that the GPSLatitude, GPSLongitude, GPSAltitude and GPSDateTime tags are all available in each processed FILE. Warnings will be generated for missing tags. The output GPX format will invalid if any GPSLatitude or GPSLongitude tags are missing, but will be OK for missing GPSAltitude or GPSDateTime tags.

David

Phil Harvey

Hi David,

Yes, the times must be in order.  Use the -fileorder option with the appropriate tag name to achieve this.
The output GPX will be valid with a missing time stamp, but it can't be used for geotagging without a valid timestamp.  Without a timestamp you have a waypoint log, not a temporal track log.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin

So when I issue

exiftool -fileOrder gpsdatetime -r -p gpx.fmt -d 2013-12-01T12:00:00Z IMG.jpg > out.gpx

I get:

Warning [Minor] 'gpsdatetime' not defined - IMG.jpg

Is this because the source file is missing the gpsdatetime info? Or is my invocation incorrect?

Thanks,

David

Phil Harvey

The file is missing the GPS date and/or time.  What is the output of:

exiftool -gps:all -a IMG.jpg

?

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin

The output for the file I am trying to get a track file for is:

GPS Latitude Ref                : North
GPS Latitude                    : 25 deg 2' 10.20"
GPS Longitude Ref               : East
GPS Longitude                   : 121 deg 31' 8.40"
GPS Altitude Ref                : Above Sea Level
GPS Altitude                    : 16.27441406 m
GPS Time Stamp                  : 02:20:38.77
GPS Img Direction Ref           : True North
GPS Img Direction               : 211.4742268

I have tried all combinations of the suggested commands and I get the warning for the missing time stamp. It appears to have one. I notice that the .fmt seems to be missing some of the tags that are in the photo. Would that matter?

Thanks,

David

Phil Harvey

You get a warning for a missing "gpsdatetime", not a missing "time stamp".

Both GPSTimeStamp and GPSDateStamp are necessary for the Composite GPSDateTime tag.  Without a date and time, the output GPX log will have no temporal information.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin


Hi Phil,

I get:

Warning: [Minor] Tag 'gpsdatetime' not defined - IMG.jpg'

So it sounds like I am missing the GPS date stamp. Is there a way to force the image to have this information? Or to fake it? If I import the photo into iPhoto I can reposition the image anywhere in the world I want to. I am trying to do this work from the command line. Is there a way to brute force this?

Thanks again,

David

Phil Harvey

Hi David,

You can fill in the GPSDateStamp from any other date/time tag like this:

exiftool "-gpsdatestamp<datetimeoriginal" FILE

Which should work OK except when you are within your time zone of midnight.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin

Thanks for the help Phil,

So with that last suggestion, I can get a clean track file created. When I try to use that track file to apply geotag info to an image that has no geo tag info using:

exiftool -geotag out.gpx BoraBora\ 36.jpg

I get:

Warning: No track points found in GPS file 'out.gpx' in File:Geotag (ValueConvInv)
Warning: GPS track is empty in File:Geotime (ValueConvInv) - BoraBora 36.jpg
Warning: No writable tags set from BoraBora 36.jpg
    0 image files updated
    1 image files unchanged

The track file does appear to have a track point (lat, long, gps time, etc). The values for the gps info after correcting the gps date stamp are these:

GPS Latitude Ref                : North
GPS Latitude                    : 25 deg 2' 10.20"
GPS Longitude Ref               : East
GPS Longitude                   : 121 deg 31' 8.40"
GPS Altitude Ref                : Above Sea Level
GPS Altitude                    : 16.27441406 m
GPS Time Stamp                  : 02:20:38.77
GPS Img Direction Ref           : True North
GPS Img Direction               : 211.4742268
GPS Date Stamp                  : 2012:09:30

So it seems that all is well. Is it choking because the values don't make sense?

Thanks for all the help,

David

davidcalvin

This is the newly created track file:


<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.0"
creator="ExifTool 9.33"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<trk>
<number>1</number>
<trkseg>
<trkpt lat="25.0361666666667" lon="121.519">
  <ele>16.27441406</ele>
  <time>2009-01-01</time>
</trkpt>
</trkseg>
</trk>
</gpx>

Phil Harvey

Why is there no time in the GPX file?  There is only a date.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin

I was wondering the same thing. The file contains this gps data (from which I am making gpx file). I tried to recreate the gpx file and now I am getting the below gpx data. I have noticed that, whenever I make a change to a file using exiftool I must touch the file for the file system to realize the change. Not sure why that is.

<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.0"
creator="ExifTool 9.33"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<trk>
<number>1</number>
<trkseg>
<trkpt lat="25.0361666666667" lon="121.519">
  <ele>16.27441406</ele>
  <time>2012:09:30 02:20:38.77Z</time>
</trkpt>
</trkseg>
</trk>
</gpx>

When I apply that GPX file to an untagged image I get:

Argument "-Geotime<DateTimeOriginal" is assumed
Loaded 0 points from GPS track log file 'out.gpx'
Warning: No track points found in GPS file 'out.gpx' in File:Geotag (ValueConvInv)
======== BoraBora 36.jpg
Setting new values from BoraBora 36.jpg
Warning: GPS track is empty in File:Geotime (ValueConvInv) - BoraBora 36.jpg
Warning: No writable tags set from BoraBora 36.jpg
Nothing changed in BoraBora 36.jpg
    0 image files updated
    1 image files unchanged

So.. the track file looks good to me. Yet its saying 0 track points loaded. I downloaded a track file from the internet for some place un Utah and, at least that track file says its loading points, but it still fails to apply the gps data to the image. Does the creation date of the photo need to be near to the gps date time stamp of the photo? Or is there something else going on?

Thanks,

David

Phil Harvey

Hi David,

We're back to the first problem.  Improper date/time formatting in the GPX file.  It should be "2012:09:30T02:20:38.77Z" (the "T" is necessary).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin


That's interesting. So the date that is actually in the gpx file needs to be that? Does that mean that the gpx template file on the web site has the wrong format since it created that output?

I will try tweaking the gpx file.

David

davidcalvin

Tweaked the GPX file. Still not working, same error. Here is the update:


<?xml version="1.0" encoding="utf-8"?>
<gpx version="1.0"
creator="ExifTool 9.33"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.topografix.com/GPX/1/0"
xsi:schemaLocation="http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd">
<trk>
<number>1</number>
<trkseg>
<trkpt lat="25.0361666666667" lon="121.519">
  <ele>16.27441406</ele>
  <time>2012:09:30T02:20:38.77Z</time>
</trkpt>
</trkseg>
</trk>
</gpx>

Phil Harvey

Quote from: davidcalvin on August 02, 2013, 01:09:39 PM
So the date that is actually in the gpx file needs to be that?

Yes.

QuoteDoes that mean that the gpx template file on the web site has the wrong format since it created that output?

No, it means that you have to use the -d option mentioned in the documentation to format the date/time correctly.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

Phil Harvey

Quote from: davidcalvin on August 02, 2013, 01:12:53 PM
Tweaked the GPX file. Still not working, same error. Here is the update:

Oops, right.  The date must be separated by "-", not ":".  Like this: "2012-09-30T02:20:38.77Z".  As per the -d option in gpx.fmt.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin

Hi Phil,

Okay. Progress is being made. When I recreated the track file, I am now getting the track point loaded, but the file is not being changed with the given gps data:


Argument "-Geotime<DateTimeOriginal" is assumed
Loaded 1 points from GPS track log file 'out.gpx'
  GPS track start: 2012:09:30 02:20:38 UTC
  GPS track end:   2012:09:30 02:20:38 UTC
Writing File:Geotag
======== BoraBora 36.jpg
Setting new values from BoraBora 36.jpg
  Geotime value:   2011:03:15 10:12:39 UTC (local timezone is -07:00)
Warning: Time is too far before track in File:Geotime (ValueConvInv) - BoraBora 36.jpg
Warning: No writable tags set from BoraBora 36.jpg
Nothing changed in BoraBora 36.jpg
    0 image files updated
    1 image files unchanged

Does this mean I need to change the creation date of the target image to match the gps date time stamp?

Thanks again,

David

Phil Harvey

Hi David,

I sort of expected this to happen.  Is there any reason why you don't just copy the GPS tags directly from the other file instead of going through a fake track log?:

exiftool -tagsfromfile SOURCE.jpg -gps:all DESTINATION.jpg

Otherwise, you could either change the time in the track log or relax the time constraint by setting GeoMaxExtSecs to an absurdly large number in the %Image::ExifTool::UserDefined::Options of the config file.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin


I will try that next (modifying the config file). Ultimately, my goal is to stamp thousands of images with GPS tags from a database of locations. My preference would be to just write the GPS tags directly to the image, but when I try to do that with exiftool it errors out and tells me that that cannot be done. I guess what I was hoping to do was figure out how to spew a track file on the fly with the coordinates that I am interested in and stamp images repeatedly as necessary.

Is there a way to just make an image have a certain lat, long, and altitude without using a track file or another image? That would be ideal.

Thanks,

David

Phil Harvey

Hi David,

Quote from: davidcalvin on August 06, 2013, 11:38:55 AM
My preference would be to just write the GPS tags directly to the image, but when I try to do that with exiftool it errors out and tells me that that cannot be done.

More details are necessary to figure out what you were doing wrong.

QuoteIs there a way to just make an image have a certain lat, long, and altitude without using a track file or another image? That would be ideal.

Sure.  Lots of ways.  Directly from the command line:

exiftool -gpslatitude=30.14155 -gpslatituderef=N -gpslongitude=70.12727 -gpslongituderef=W FILE

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

davidcalvin

Hi Phil,

That seems to work. However, it turns negative numbers into positive ones:

overwrite_original  -gpslatitude='37.322944' -gpslongitude='-122.032305' '/Users/david/Pictures/LBReplicateCache/IMG_1504-1.CR2'

-a -u -g1 /Users/david/Pictures/LBReplicateCache/IMG_1504-1.CR2 | grep GPS


---- GPS ----
GPS Version ID                 : 2.3.0.0
GPS Latitude                    : 37 deg 19' 22.60"
GPS Longitude                  : 122 deg 1' 56.30"
GPS Position                    : 37 deg 19' 22.60", 122 deg 1' 56.30"

Is there a reason for this?

Thanks,

David

davidcalvin

I am guessing this is due to the neat for the ref parameter? The GPS Data I am working with doesn't  supply references, so I guess I have to detect negative/ positive and provide the refs?

Phil Harvey

Hi David,

Yes.  The EXIF GPS hemisphere is unfortunately stored separately (dumb, really).

But ExifTool is smart this way.  Just set the GPSLatitude/LogitudeRef to the same signed number as GPSLatitude/Longitude and it will assign the proper hemisphere.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tadej

Hi David,

newbie but trying hard.  8)
I tried to write lat and long to image file as suggested
exiftool -gpslatitude=30.14155 -gpslatituderef=N -gpslongitude=70.12727 -gpslongituderef=W jpg.jpg

An error is generated.
Error: Error reading StripOffsets data in IFD1

Does this mean that image has no gps tags yet and they must be added prior to write.

If yes, how do I add tags which are regular ones but do not exist in image.

Kind Regards


Phil Harvey

This error means that the EXIF is corrupted.  Read FAQ 20 for help fixing this.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tadej

Thanks Phil, works like magic.
But weird thing is that image wa taken by Cannon and was resized in Photoshop and saved.
Is there a simple way (not try-to-wite) to test if Exif is not corrupted.

I get Exif values when read is performed.
What exactly do you mean by saying Exif is corrupted.

Dusan

Phil Harvey

In this case, a bad IFD1:StripOffsets would mean that the thumbnail image is garbage.

You may get a warning about this if you run exiftool -warning jpg.jpg, but I'm not sure.  In general, more validation is done when writing than when reading images (because data integrity is more important than speed when writing).

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tadej

Thanks Phil,

-warning does not return anything. Will perform real write and perform accordingly.
Last question for today:
How do I read only one specific Exif tag.
exif -???? file

regards Dusan

Phil Harvey

The syntax is: exiftool -TAG FILE

ie) exiftool -artist test.jpg

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tadej

Thanks Phil for being patient with me.
It works great.
I have included Shell mode in my VB.NET program.
I am considering to go commercial at some point.
What are terms and conditions if I would use your ExifTool.exe
Regards, Dusan
P.S. I have never seen such consistent and passionate approach to manage such a mess and inconsistency which abused Exif actually embodies. Yo've got my 10 out of 5.
:)

Phil Harvey

Hi Dusan,

Thanks for the compliments.

ExifTool is free to use inside another application with some conditions.  See the Perl artistic license for details.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tadej

Hi Phil,

that is fine. As I am not USA or UK resident it is difficult to understand (from legal point of view - wording, expessions, assumptions - usually the culture stuff )  what I am supposed to do if I distribute and call your exe from my VB.NET product.
Please enlighten me.

Thanks and Regards,
Dusan

Phil Harvey

Hi Dusan,

If your product is free, then there are no restrictions.

If you sell your product, then it must provide some value-added functionality, and not simply be an overt attempt to sell ExifTool by exposing ExifTool's functionality through a thin user interface.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tadej

Hi Phil,

the system, GUI an functionality will be (are) thick, very thick.
What wording would you like to see in About Box.
I am perfectly happy to promote your excellent work.
I know the time will come for a a suitable donation.
Currently  am recovering from a disaster  >:(.

Regards,
Dusan

Phil Harvey

Hi Dusan,

I hope your disaster recovery goes well.

What you put in an about box, if anything, is entirely up to you.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tadej

Hi Phil,

I have come to the last stage of my development where I have to write the following data into jpg image:
longitude,
latitude,
altitude in meters,
true north camera orientation,
UTC time of picture taken.

Is there a command line example which I can test without a lot of try and error approach.

Kind regards,
Dusan

Phil Harvey

Hi Dusan,

The command will look something like this:

exiftool -gpslatitude=VAL -gpslatituderef=north -gpslongitude=VAL -gpslongituderef=west -gpsaltitude=VAL -gpsaltituderef=above -gpsimgdirection=VAL -gpsimgdirectionref=true -gpsdatestamp=2014:01:12 -gpstimestamp=19:56:59 image.jpg

See FAQ 14 for more information about valid coordinate formats.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

tadej

Hi Phil,

works like magic.
I have added three additional fileds:
Title, Description, Type. Are there standarized tages where can I write this information, what are the limits of text size and how actually command to write all three looks like.

Are there any tags which tell what is viewing angle of camera lenses.

Kind regards,
Dusan


Phil Harvey

Hi Dusan,

There are no ExifTool-imposed limits on text size.  There is a command-line length limitation in Windows, but not Mac/Linux.

There is a Composite FOV tag that ExifTool calculates to give the field of view in degrees.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).