ExifTool Forum

ExifTool => Newbies => Topic started by: leomessi10 on July 18, 2020, 07:56:10 AM

Title: Aligning two photos to my modified date ignoring GPS
Post by: leomessi10 on July 18, 2020, 07:56:10 AM
Hello, I've tried to follow the documentation an Google but perhaps missing something easy here.
If I understand correctly (keep me honest here), while my Mac will sort items by "Modifed Date", then Iphone will sort photos by many other parameters which I can access using the command "exiftool -time:all -G1 -a -s".
Sometimes, my photos HAVE GPS location data. They might have GPS timestamp but I tend to reset it, as my interest is that the date will ALWAYS be what I define in "Modified date". However, I find myself in a situation where the order is just wrong.

exiftool -time:all -G1 -a -s a.JPG
[System]        FileModifyDate                  : 2015:11:25 19:53:12+02:00
[System]        FileAccessDate                  : 2020:07:18 14:43:28+03:00
[System]        FileInodeChangeDate             : 2020:07:18 14:43:27+03:00
[IPTC]          DateCreated                     : 2015:11:25
[IPTC]          TimeCreated                     : 19:53:12+02:00
[Composite]     DateTimeCreated                 : 2015:11:25 19:53:12+02:00
[Composite]     DateTimeOriginal                : 2015:11:25 19:53:12+02:00


exiftool -time:all -G1 -a -s b.JPG
[System]        FileModifyDate                  : 2015:11:25 21:40:00+02:00
[System]        FileAccessDate                  : 2020:07:18 14:43:28+03:00
[System]        FileInodeChangeDate             : 2020:07:18 14:43:27+03:00
[IPTC]          DateCreated                     : 2015:11:25
[IPTC]          TimeCreated                     : 21:40:00+02:00
[Composite]     DateTimeCreated                 : 2015:11:25 21:40:00+02:00
[Composite]     DateTimeOriginal                : 2015:11:25 21:40:00+02:00


The first photo was taken less than two hours before, however, it has a GPS location which is two hours earlier, so it is displayed after the first one.
What am I missing? and can I have a script that will delete ALL timestamps over a photos, and just use one unified parameter? I used so far something like this, but this is not catching all my problems


exiftool -P -v -api QuickTimeUT "-FileModifyDate>AllDates" *
exiftool -P -v -api QuickTimeUT "-FileModifyDate>DateTimeOriginal"  *
exiftool -P -v -api QuickTimeUT "-FileModifyDate>Quicktime:CreationDate" "-FileModifyDate>DateCreated" "-FileModifyDate>IPTC:DateCreated" "-FileModifyDate>IPTC:TimeCreated" *
exiftool -P -v -api QuickTimeUT "-FileModifyDate>GPSDateStamp" "-FileModifyDate>GPSTimeStamp" -globalTimeShift *
exiftool -P -v -alldates= -gpsdatestamp= -gpstimestamp= *



Thanks a lot!
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: StarGeek on July 18, 2020, 12:42:20 PM
Quote from: leomessi10 on July 18, 2020, 07:56:10 AM
The first photo was taken less than two hours before, however, it has a GPS location which is two hours earlier, so it is displayed after the first one.
What am I missing?

If the time zone indicated is correct, then the GPS time is correct.  GPS time stamps must be in UTC, otherwise any program that tries to deal with GPS data will be inaccurate.
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: Alan Clifford on July 18, 2020, 02:40:32 PM
QuoteI find myself in a situation where the order is just wrong.

The order is just wrong when you do what?
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: leomessi10 on July 18, 2020, 03:05:33 PM
Thanks for answering, but I'm not sure I was clear enough.
What I have is, for the sake of the example, is two photos taken during the same trip. Since one of them was with my phone it has GPS location, while the second one, coming from whatsapp, has no such location, so its timezone might be my own which is 2 hours later.
When I import them to my Iphone, they are ordered "inaccurately", as Photo A was taken at 19:53 + 2 == 21:53 (according to GPS) and Photo B was taken at 21:40 (no GPS data).
My goal is to master their timestamps through one column unified; in other words, I want to be able to set my own "FileModifyDate" so its neglects GPS data (please note that I have used -gpsdatestamp= -gpstimestamp= so I expected it to work; also, this method has worked for me in the past with other photos).

Given that, StarGeek, I'm not really sure how I can solve this problem. I want to keep the GPS tags on photo A, but I want my modify time to acknowledge it. And ideally I would love a robust solution, to apply the same code in all my photos (but I'm also fine with adding somehow +2 to this specific trip, I just don't know how).
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: StarGeek on July 18, 2020, 05:16:36 PM
I'm having trouble understanding how the times could be taken only 13 minutes apart yet have a 2 hour difference if they were taken on the same device.  The FileModifyDate would be handled by the device and would be correct as long as the device had the correct time, regardless of the app it was saved from.

But I would say your best course would be to shift the time in the incorrect file.  The FileModifyDate is easy to shift but the IPTC:DateCreated and IPTC:TimeCreated are a bit more complex as they're separate tags.  If  time portion is too close to midnight and you shift past that, the date portion wouldn't be updated properly.  But a combination of the GlobalTimeShift option (https://exiftool.org//exiftool_pod.html#globalTimeShift-SHIFT) and -TagsFromFile option (https://exiftool.org/exiftool_pod.html#tagsFromFile-SRCFILE-or-FMT) could do it like this.  For example, adding two hours to the time stamps
exiftool -GlobalTimeShift +2 -TagsFromFile @ -FileModifyDate "-IPTC:DateCreated<DateTimeCreated" "-IPTC:TimeCreated<DateTimeCreated" /path/to/files/
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: leomessi10 on July 18, 2020, 07:54:48 PM
Hi StarGeek, thanks. Your answer is getting me closer, but I'm still lacking one more part.

I will explain my goal again, although I'm not sure if it's crucial. First of all, forget about how "FileModifyDate" was originally created - assume I have ran over this field already from my computer, as along the years I had different devices and I changed that field quite a lot without giving it too much tought, as I wasn't aware of how complex this world is  :)

I have two photos from the same trip with a friend.
Photo A was taken with my device, thus, it has also GPS tags etc.
Photo B was taken LESS than 2 hours later with HIS device. He whatsapped me the photo later on - and thus, it has no GPS tags.
My goal is now to have an album with these photos in chronological order. "FileModifyDate" shows "2015:11:25 19:53:12+02:00" for A and "2015:11:25 21:40:00+02:00" for B. However, A has GPS data. My iphone considers that information and bumps its timestamp with 2 hours.
My real problem is that I have MULTIPLE photos from both sources, and thus it's a whole mess. More generally, this happens with almost every trip I had - some photos were with my device, some with other devices, some were whatsapped etc. I manually edited the field "FileModifyDate" so when I order them by that field, it makes sense. However, when I import them, the photos with location behave differently than photos without location.

I have two main goals:
1. Keeping the "modified" system field in chronological order. Right now it is.
2. When importing to my Iphone, letting it realize that the modified date IS the actual timestamp, regardless of GPS timestamp.

Regarding your solution:
I'm actually not sure it's good for me, since, I still want to keep myself the option of sorting in my Mac by "date modified" in the finder (presumably that field) and be able to see them in chronological order.
Even if I was tackling it with your solution, I will be missing a simple line of code here: photo A has GPS (location) tags, while photo B does not. Probably I would love to run the command with some "IF" - do the +2 thing only IF I have GPS tags. Then, I can run the same query for every trip, just changing the "2" paremeter. The GPS values are written below, but probably I would like a more general thing saying something like "consider any GPS tag you have".
The best thing, probably, will not be changing "FileModifyDate" but perhaps creating a GPS timestamp like "gpsdatestamp", "gpstimestamp".

[GPS]           GPSLatitudeRef               
[GPS]           GPSLatitude
[GPS]           GPSLongitudeRef
[GPS]           GPSLongitude
[GPS]           GPSAltitudeRef
[GPS]           GPSAltitude
[GPS]           GPSSpeedRef
[GPS]           GPSSpeed
[GPS]           GPSImgDirectionRef
[GPS]           GPSImgDirection
[GPS]           GPSDestBearingRef
[GPS]           GPSDestBearing


Thanks a million.
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: Alan Clifford on July 19, 2020, 08:15:23 AM
Break this down into the two problems.  First is the mess that is timezones.  Second is the different tags your different devices use for sorting.

My suggestion for timezones is what I do.  I create an xmp:datetimeoriginal, which allows timezones, in all my photos.  I'm happy to discuss/share how I do this for my different cameras.  This makes all your photos have a consistent place for the date and time.

You need to work out which tags your devices are using for sorting and set them.

On my mac, I can use
exiftool '-filemodifydate<xmp:datetimeoriginal' p340_1700.jpg

and display it with
ls -lT p340_1700.jpg

Before value 19 Jul 12:50:30 2020 p340_1700.jpg
After value 12 Feb 15:34:58 2019 p340_1700.jpg

exiftool displays for the xmp:datetimeoriginal 2019:02:12 17:34:58+02:00

which matches as I am in the UK and in February, we'd be on +00


Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: leomessi10 on July 19, 2020, 01:07:28 PM
Jesus, Alan! I think you solved it  8)

I will just mention that I had "warning: no writable tags set from" so I did it like this:

exiftool -P -v -AllDates= -DateTimeOriginal= -DateCreated= -Quicktime:CreationDate= -XMP-photoshop:DateCreated= -XMP-photoshop:DateCreated= -xmp:datetimeoriginal= -IPTC:DateCreated= -IPTC:TimeCreated= -GPSDateStamp= -GPSTimeStamp= -TrackCreateDate= -TrackModifyDate= -MediaCreateDate= -MediaModifyDate= -ContentCreateDate= *
exiftool -P -v '-FileModifyDate>xmp:datetimeoriginal' *
exiftool -P -v '-FileModifyDate<xmp:datetimeoriginal' *


Thanks a lot for your efforts. I really hope this is over!
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: leomessi10 on July 19, 2020, 03:11:33 PM
So... sadly, it works only partially. I can't remove the tag "ICC-header:ProfileDateTime".

"Warning: Sorry, ProfileDateTime is not writable
Nothing to do."

Now, same story. Photo A has GPS, photo B doesn't. They appear in different order. What am I doing wrong? I want it to ignore GPS  :'(

======== a.JPG
[System]        FileModifyDate                  : 2019:07:02 10:09:14+03:00
[System]        FileAccessDate                  : 2020:07:19 22:04:31+03:00
[System]        FileInodeChangeDate             : 2020:07:19 22:08:20+03:00
[XMP-exif]      DateTimeOriginal                : 2019:07:02 10:09:14+03:00
[ICC-header]    ProfileDateTime                 : 2017:07:07 13:22:32
======== b.JPG
[System]        FileModifyDate                  : 2019:07:02 10:34:26+03:00
[System]        FileAccessDate                  : 2020:07:19 22:04:31+03:00
[System]        FileInodeChangeDate             : 2020:07:19 22:08:20+03:00
[XMP-exif]      DateTimeOriginal                : 2019:07:02 10:34:26+03:00
[ICC-header]    ProfileDateTime                 : 2017:07:07 13:22:32
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: Alan Clifford on July 19, 2020, 04:11:07 PM
When you say "it", we are not sure what "it" is that you want to ignore gps. And are you sure that gps is causing the problem?

I wasn't suggesting that setting filemodifydate would solve the problem.  That was just an example of how to set a tag from xmp:datetimeoriginal.  You need to identify which tags are used by each of your device/program combinations that are used in the sort.

But if gps date and time are the culprit, we can put that in the photo that doesn't have it.

As an example, we start with a photo with xmp:datetimeoriginal, which I suggested putting in all your photos as a standard way of storing the date and time with timezone.

exiftool -a -G  -s  p340_1700.jpg -gpstimestamp -gpsdatestamp -gpsdatetime -datetimeoriginal
[EXIF]          DateTimeOriginal                : 2019:02:12 17:34:58
[XMP]           DateTimeOriginal                : 2019:02:12 17:34:58+02:00


Then put the date and time into the gps fields

exiftool '-gpstimestamp<xmp:datetimeoriginal' '-gpsdatestamp<xmp:datetimeoriginal' '-gpsdatetime<xmp:datetimeoriginal'  p340_1700.jpg

Display the tags again

exiftool -a -G  -s  p340_1700.jpg -gpstimestamp -gpsdatestamp -gpsdatetime -datetimeoriginal
[EXIF]          GPSTimeStamp                    : 15:34:58
[EXIF]          GPSDateStamp                    : 2019:02:12
[XMP]           GPSDateTime                     : 2019:02:12 17:34:58+02:00
[Composite]     GPSDateTime                     : 2019:02:12 15:34:58Z
[EXIF]          DateTimeOriginal                : 2019:02:12 17:34:58
[XMP]           DateTimeOriginal                : 2019:02:12 17:34:58+02:00


Note that exiftool has wonderfully modified the gpstimestamp to UTC.


Alternatively, you could remove the gps tags from the photo that has them.  Assuming, of course, that you don't want the gps information.


Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: leomessi10 on July 19, 2020, 05:01:35 PM
I'm sorry, I feel that I'm wasting your time. I carefully read your explanation but probably the problem is me not being clear. I will write it again  :) I really hope you don't give up on me.

When you say "You need to identify which tags are used by each of your device/program combinations that are used in the sort", that's probably important. I'm not really sure how to identify it. The two applications I'm using, though, are quite common and I guess that you'll know which tags they use (and please, let me know how can I check it):

1. MacBook's Finder. Here I just have the files, and I want to sort them by "Date Modified". I'm not really sure which Tag maps to it, but here I don't have any problems, and I assume it's "FileModifyDate".
2. Apple's "PHOTOS" application, both in Mac or my Iphone, it doesn't matter. Here, I'm positive that many other tags are considered, and I'm also sure that GPS location affects somehow. I think that because when importing a bunch of photos of the same trip, that according to "FileModifyDate" are correctly sorted, then I find myself with a conflict: photos without GPS location metadata maintain their inner order, and photos with GPS location do it as well. However, seeing all of them together is terrible, as they are mixed between each other. Basically, the two types of photos are not synced. Also, I'm quite sure that when I removed GPS Location tags (just as a trial), the problem was "solved", but I lost my GPS Location metadata (which I DO want to keep!).

I hope now we are clear regarding the two applications I use, and why I suspect that the problem is related to the fact that some photos have GPS location.

If we stick with the last example, the time metadata of photos A and B seems exactly the same to me. A was taken before B, nothing contradicts that.

exiftool -time:all -G1 -a -s

======== a.JPG
[System]        FileModifyDate                  : 2019:07:02 10:09:14+03:00
[System]        FileAccessDate                  : 2020:07:20 00:04:07+03:00
[System]        FileInodeChangeDate             : 2020:07:20 00:04:05+03:00
[GPS]           GPSTimeStamp                    : 07:09:14
[GPS]           GPSDateStamp                    : 2019:07:02
[XMP-exif]      GPSDateTime                     : 2019:07:02 10:09:14+03:00
[ICC-header]    ProfileDateTime                 : 2017:07:07 13:22:32
[Composite]     GPSDateTime                     : 2019:07:02 07:09:14Z
======== b.JPG
[System]        FileModifyDate                  : 2019:07:02 10:34:26+03:00
[System]        FileAccessDate                  : 2020:07:20 00:04:06+03:00
[System]        FileInodeChangeDate             : 2020:07:20 00:04:05+03:00
[GPS]           GPSTimeStamp                    : 07:34:26
[GPS]           GPSDateStamp                    : 2019:07:02
[XMP-exif]      GPSDateTime                     : 2019:07:02 10:34:26+03:00
[ICC-header]    ProfileDateTime                 : 2017:07:07 13:22:32
[Composite]     GPSDateTime                     : 2019:07:02 07:34:26Z


However, importing it into PHOTOS app shows them in a different order. As you can see, Photo A has GPS Location metadata, while B doesn't.

exiftool -G1 -a -s -GPSLatitude *
======== a.JPG
[GPS]           GPSLatitude                     : 19 deg 55' 47.20"
[Composite]     GPSLatitude                     : 19 deg 55' 47.20" S
======== b.JPG
    2 image files read


Does this make more sense?
Thanks a lot!
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: StarGeek on July 19, 2020, 05:26:28 PM
Quote from: leomessi10 on July 19, 2020, 03:11:33 PM
So... sadly, it works only partially. I can't remove the tag "ICC-header:ProfileDateTime".

Don't worry about this tag.  It's not a tag that any software would ever use to sort with.  It's part of the ICC profile andyou don't want to remove the ICC profile as it might significantly change the colors of your images.
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: leomessi10 on July 20, 2020, 03:55:54 AM
Thanks StarGeek, I won't. The best result I have so far is this:

exiftool -P -v -AllDates= -DateTimeOriginal= -DateCreated= -Quicktime:CreationDate= -Quicktime:CreateDate= -XMP-photoshop:DateCreated= -XMP-photoshop:DateCreated= -xmp:datetimeoriginal= -IPTC:DateCreated= -IPTC:TimeCreated= -GPSDateTime= -GPSDateStamp= -GPSTimeStamp= -TrackCreateDate= -TrackModifyDate= -MediaCreateDate= -MediaModifyDate= -ContentCreateDate= *

exiftool -P -v -api QuickTimeUTC "-FileModifyDate>GPSDateStamp" "-FileModifyDate>GPSTimeStamp"  "-FileModifyDate>GPSDateTime"   -globalTimeShift -TagsFromFile *


This seems to work as expected with photos, but not with videos (and also with a PNG image). I don't have a very solid idea of what I'm doing here. The first row is obviously attempting to "drop everything except the FileModifyDate". The second row tries to tell Iphone photos to ignore GPS shifts and considering "FileModifyDate" as the absolute timestamp. I did some trial and error, but with these commands it doesn't seem to work perfectly - it seems like the videos are now displayed in the end, while photos are correctly ordered in PHOTOS app (meaning, it doesn't matter if they have GPS location, they will follow "FileModifyDate").
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: leomessi10 on July 20, 2020, 08:18:18 AM
And I continue to spam myself, but, it seems that right now this piece of code does exactly what I wanted (for a quite rich example):

exiftool -P -v -AllDates= -CreationDate= -DateTimeOriginal= -DateCreated= -Quicktime:CreationDate= -Quicktime:CreateDate= -XMP-photoshop:DateCreated= -XMP-photoshop:DateCreated= -xmp:datetimeoriginal= -IPTC:DateCreated= -IPTC:TimeCreated= -GPSDateTime= -GPSDateStamp= -GPSTimeStamp= -TrackCreateDate= -TrackModifyDate= -MediaCreateDate= -MediaModifyDate= -ContentCreateDate= - *
exiftool -P -v -if '$filetype eq "MOV" or $filetype eq "mov"' -api QuickTimeUT "-FileModifyDate>Quicktime:CreationDate" *


No idea what was going on and I hope I'm not back to ask  :o
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: Alan Clifford on July 20, 2020, 10:19:42 AM
Quote from: leomessi10 on July 19, 2020, 05:01:35 PM

However, importing it into PHOTOS app shows them in a different order. As you can see, Photo A has GPS Location metadata, while B doesn't.


Both photos have gps time tags but only one has gps location tags?  Hmmm, I wonder if the apple app is being "helpful" and deriving a timezone from the location data.

Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: StarGeek on July 20, 2020, 11:37:55 AM
Quote from: leomessi10 on July 20, 2020, 03:55:54 AM
This seems to work as expected with photos, but not with videos (and also with a PNG image).

Support of metadata in PNG files is severely lacking in most software.  PNG:CreationTime is most likely to be supported, though Google Photos actually supports EXIF data in PNG files. 

For videos, Quicktime:CreateDate is probably the best one to use, though if you use Apple Photos, Quicktime:DateTimeOriginal seems to get priority but you MUST make sure that the time zone is included otherwise you get very weird results.
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: leomessi10 on July 20, 2020, 01:48:47 PM
Hey guys, I really don't know what was going on. The "scripts" I provided during this process didn't achieve what I wanted. Only the last one worked to achieve my goals, this is the one:

exiftool -P -v -AllDates= -CreationDate= -DateTimeOriginal= -DateCreated= -Quicktime:CreationDate= -Quicktime:CreateDate= -XMP-photoshop:DateCreated= -XMP-photoshop:DateCreated= -xmp:datetimeoriginal= -IPTC:DateCreated= -IPTC:TimeCreated= -GPSDateTime= -GPSDateStamp= -GPSTimeStamp= -TrackCreateDate= -TrackModifyDate= -MediaCreateDate= -MediaModifyDate= -ContentCreateDate= -ContentCreateDate-heb= *
exiftool -P -v -if '$filetype eq "MOV" or $filetype eq "mov"' -api QuickTimeUT "-FileModifyDate>Quicktime:CreationDate" *


Thank you both for assisting and for all the patience. Going forward I'm thinking of doing a few things:
1. Not relying only on FileModifyDate as my "source of truth", since it can be easily rewritten - for example if I rotate the photo or something. I think that I could indeed use "xmp:datetimeoriginal" to be it. I'm a bit afraid that Apple PHOTOS will be confused, but I can give it a try, what the heck.
2. I could be nice to add GPS location to photos which location is missing, especially those abroad, it will help avoiding this issue. In general, I will probably want always to take the location of the preceding/following photo. Is there an easy way to copy all GPS Location tags from one photo to another one?

Thanks!
Alan
Title: Re: Aligning two photos to my modified date ignoring GPS
Post by: StarGeek on July 20, 2020, 03:59:35 PM
Quote from: leomessi10 on July 20, 2020, 01:48:47 PM
exiftool -P -v -AllDates= -CreationDate= -DateTimeOriginal= -DateCreated= -Quicktime:CreationDate= -Quicktime:CreateDate= -XMP-photoshop:DateCreated= -XMP-photoshop:DateCreated= -xmp:datetimeoriginal= -IPTC:DateCreated= -IPTC:TimeCreated= -GPSDateTime= -GPSDateStamp= -GPSTimeStamp= -TrackCreateDate= -TrackModifyDate= -MediaCreateDate= -MediaModifyDate= -ContentCreateDate= -ContentCreateDate-heb= *

AllDates is a short cut for CreateDate, DateTimeOriginal, and ModifyDate, so when you set -AllDates=, you don't need to clear DateTimeOriginal, Quicktime:CreateDate, or xmp:DateTimeOriginal.

You can use a wild card to trim down the video time stamps.  For example,
-Track*Date= -Media*Date= -Content*Date=

QuoteIs there an easy way to copy all GPS Location tags from one photo to another one?
exiftool -TagsFromFile Source.jpg -GPSLatitude* -GPSLongitude* Target.jpg

This will copy the Latitude and Longitude and the associated Ref tags.  To add Altitude, add -Altitude*.  Or to copy all gps tags, -GPS*.