GEOTAG issues - HELP

Started by mtndewdewd, July 16, 2016, 03:04:31 AM

Previous topic - Next topic

mtndewdewd

I have looked through the example and played with them for a few hours and I can't seem to get done what I am needing. I played with exporting TAGS to a GPX log and a CSV without any luck. Hoping someone can easily drop some commands out here for me to use to get done what I need.

My main issue is that an application (Flir Tools+) destroys the GEOTAG data in the file during editing and saving.

My need is:

1) EXPORT all GEOTAG information (only Lat/Lon/Alt required, all other info would be nice) from all files in a directory
...i will then edit all those files in the directory - names will stay the same - and GEO information will be removed...
2) Use the exported data file created in #1 above to re-GEOTAG all files in the folder based on name


Thanks in advance for any direction / help anyone can provide!

Phil Harvey

I would suggest creating a sidecar file containing the metadata then copying the metadata back again from that.  Since you are interesting in GPS information, probably an EXIF sidecar is what you want.  You could use the last command in the EXIF section on this page to create the sidecar files:

exiftool -o %d%f.exif -all -unsafe DIR

Then restore whatever information you want afterwards.  For example, to do the GPS:

exiftool -tagsfromfile %d%f.exif -gps:all DIR

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

mtndewdewd

Thank you.

I gave it a try, and it seems that the GPS info was not restored. Here is the output:

D:\test\orig>exiftool -tagsfromfile %d%f.exif -gps:all d:\test\orig
Warning: [minor] Entries in IFD0 were out of sequence. Fixed. - d:/test/orig/flt
1_00__0836.jpg
Error: [minor] GPS pointer references previous ExifIFD directory - d:/test/orig/
flt1_00__0836.jpg
    1 directories scanned
  137 image files updated
    1 files weren't updated due to errors

D:\test\orig>

Phil Harvey

What makes you think the GPS was not restored?  Did you look with ExifTool?

Also, I should have added --ext exif to both commands to avoid processing .exif files.

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

mtndewdewd

I was using the geosetter tool... I could map the image and in geosetter the exifo shows the location before and shows the pin, and after the edit and re-tagging with the command you gave me the GPS info in not in the exif section and will not map the image.

Attached is a log of the entire chain of original image, after edit, after re-tagging (tagsfromfile command).

Let me know what you think.

Hayo Baan

I think the problem is that the GPS info is corrupted by your image editor (amongst the others, the warning about the GPS pointer referencing the previous IFD is caused by the editor). When you then load the tags from the exif file, I think what happens is that exiftool corrects the errors/warnings by e.g., removing the original GPS info block, but then "forgets" to write the (new) GPS data. @Phil, could this be the case?
Hayo Baan – Photography
Web: www.hayobaan.nl

mtndewdewd

If that was the case, wouldn't running it a 2nd time work? I can try to re-tag them over and over and get the same error each time and no GPS tags are written into the exif of the jpg.

Any other thoughts on this? I have a geofile in CSV format that has %imagename%,lat,lon,alt..... is there anyway to get exiftool to use this csv to tag the files other than using a sidecar file?

Thanks again for the help.

Hayo Baan

Hmm weird that you get it every time, can you post a sample jpg and .exif file so I can have a look?
(The csv way should be possible to get to work too, by the way)
Hayo Baan – Photography
Web: www.hayobaan.nl

mtndewdewd

Attached... have run a few times so you see the multiple version...

pre-editing is a working file with valid GPS info

post-editing is the jpg after editing where the gps info is gone

Hayo Baan

Ok, I found the problem. Because there is an error in the metadata of your image file, exiftool refuses to write the changes (you must have gotten 0 image files updated,  1 files weren't updated due to errors as result).

As they are minor, you should be able to simply use the -m option to ignore these and have exiftool fix the issues. However in this case this does not work (directly); if you use -m, exiftool gives you two warnings: Warning: GPS pointer references previous ExifIFD directory - T.jpg, Warning: Deleting duplicate GPS directory - T.jpg and tells you that the file wasn't changed (@Phil, this seems like a bug to me in this case as it did delete a duplicate block!).

I found a work-around, however. By first forcing a change to the file resulting in exiftool removing the erroneous GPS block and then adding the GPS info back in, I got all the data in! I used datatime original as that tag was emptied by your FLIR editing software anyway.
exiftool -m -tagsfromfile %d%f.exif -DateTimeOriginal FILES_DIRS
exiftool -tagsfromfile %d%f.exif -gps:all FILES_DIRS


@Phil, shouldn't exiftool be able to handle this as originally proposed by you (adding the -m option)?

Another work-around may be to save the metadata prior to editing like you do now but then also remove the GPS data from the file. If you then edit the file with your FLIR software, my guess is that you should be able to restore the GPS data as originally suggested (even without -m option).

Note: to me it seems the problems all start with the FLIR editing software; not only does it corrupt the GPS metadata, other metadata is mangled/removed as well (e.g. Data Time Original, Make, Camera Model Name, Focal Length, Exposure Time). I think you should complain to the makers of that software about this so they can fix it.
Hayo Baan – Photography
Web: www.hayobaan.nl

Phil Harvey

I get this:

> exiftool post-editing/flt1_01__0426.jpg -tagsfromfile pre-editing/flt1_01__0426.exif -gps:all -m -a
Warning: GPS pointer references previous ExifIFD directory - post-editing/flt1_01__0426.jpg
Warning: Deleting duplicate GPS directory - post-editing/flt1_01__0426.jpg
    0 image files updated
    1 image files unchanged


In this case the bad GPS directory was deleted but then the GPS information wasn't added (because there was no GPS directory to put it in), and since no information that you specified was actually changed exiftool didn't update the file.

I will look into changing this.  It would make more sense if ExifTool would create a new GPS directory to replace the one that was deleted if GPS information is being written.  But I'm not really sure why a bad GPS directory is flagged as a minor error.  I'll have to think about this.  Losing GPS information is significant.

The best way forward right now is to force deletion of the bad GPS information, in which case ExifTool will properly re-create the GPS directory:

> exiftool post-editing/flt1_01__0426.jpg -gps:all= -tagsfromfile pre-editing/flt1_01__0426.exif -gps:all -m -a
    1 image files updated


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

Hayo Baan

Quote from: Phil Harvey on July 18, 2016, 07:47:10 AM
I get this:

> exiftool post-editing/flt1_01__0426.jpg -tagsfromfile pre-editing/flt1_01__0426.exif -gps:all -m -a
Warning: GPS pointer references previous ExifIFD directory - post-editing/flt1_01__0426.jpg
Warning: Deleting duplicate GPS directory - post-editing/flt1_01__0426.jpg
    0 image files updated
    1 image files unchanged


In this case the bad GPS directory was deleted but then the GPS information wasn't added (because there was no GPS directory to put it in), and since no information that you specified was actually changed exiftool didn't update the file.

I will look into changing this.  It would make more sense if ExifTool would create a new GPS directory to replace the one that was deleted if GPS information is being written.
That's what was my assumption too, so I was surprised that ExifTool didn't behave this way :)

Quote from: Phil Harvey on July 18, 2016, 07:47:10 AM
But I'm not really sure why a bad GPS directory is flagged as a minor error.  I'll have to think about this.  Losing GPS information is significant.
AFAIK, you flag other bad IFD stuff as minor too. So I think it is OK to flag it as minor in this case as well.

Quote from: Phil Harvey on July 18, 2016, 07:47:10 AM
The best way forward right now is to force deletion of the bad GPS information, in which case ExifTool will properly re-create the GPS directory:

> exiftool post-editing/flt1_01__0426.jpg -gps:all= -tagsfromfile pre-editing/flt1_01__0426.exif -gps:all -m -a
    1 image files updated

Nice, your way is much neater than my two step approach :)
Hayo Baan – Photography
Web: www.hayobaan.nl

mtndewdewd

Awesome. Thanks guys. I will give it a try and let you know but based on your testing I am confident it will work great.

Phil Harvey

#13
I've looked into this and the next release of ExifTool (10.24) will be able to add back tags in cases like this without having to manually delete the directory.

- Phil

Edit: After thinking about this more I realize why ExifTool behaved the way it did.  I remember some cases where there were, for example, duplicate ExifIFD's in IFD0 and IFD1.  In this case, when writing a tag to the ExifIFD you want the second ExifIFD to be deleted completely, and not recreated with the new tag.  So I think it is safest to leave things the way they were.  Especially since it is easy to get ExifTool to recreate the directory if it should be there (by manually deleting it first), but if I made this change it would be hard to get ExifTool to delete just one of the duplicate directories.
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

mtndewdewd

This does work great.

Quick question... it seems that exiftool can perform a task on all files in a directory without writing a script to call exiftool.exe over and over.

Based on that, can you help with the syntax to use to get this to work on all files in a directory?

directory with .exif files = d:\tags

directory with .jpg files = d:\images

What exiftool command/syntax would apply tags from the .exif files in d:\tags to all jpg files in the d:\images directory?


I even tried copying the exif files and the jpg files to the same dir and running this and it did not work.

exiftool *.jpg -gps:all= -tagsfromfile *.exif -gps:all -m -a


Thanks in advance for the help