Time offset in exif data

Started by daniello, January 14, 2020, 06:41:51 AM

Previous topic - Next topic

daniello

Hi everyone,

my camera date had an offset of about 1:30 Hours and I need to correct this. I can think of two options which would work. a) rename the file to date-time format incl. the compensation for the offset and then use exiftool to adapt the exif tags. b) Do the change with exiftools directly .. if this works. Could somebody help we with this .. especially with the correct code to run the batch?
For renaming the files I can easily use NameExif .. which let's me consider the offset .. but what then?

Ultimately I need this for google photos which seems to sort by exif data and not by filename.

daniello

daniello

#1
In the meantime I found this:

exiftool "-alldates<filename" "j:\foldername\"

which renames the exif data according to the filename .. which is a way that works for me.

Only noticeable downside is that rendering takes ages .. seems to rewrite the file .. for 2000 plus image something that should be done overnigt (Intel Core i9)

Furthermore .. what I don't like about this method is that the filedate is touched. In fact it would be good to have the filedate also changed to the updated information that is written to the exif date tag.

daniello

Speed is much better when running from local SSD - my USB3 USB Stick seemed to be the problem.
File date can be updated acc to exif tag via jhead.exe

I suppose everything can be done with exiftool .. but the way I did it now works for me .. regardless of it not being terribly convenient.

Alan Clifford

exiftool  -exif:datetimeoriginal+=1:30 file.jpg

depending in which dates you want to change, in which direction or if you want to do a whole directory.

There are examples in the documentation - type exiftool on the command line.  For example,
Quoteexiftool -DateTimeOriginal-='0:0:0 1:30:0' dir
            Adjust original date/time of all images in directory "dir" by
            subtracting one hour and 30 minutes.  (This is equivalent to
            "-DateTimeOriginal-=1.5".  See Image::ExifTool::Shift.pl for
            details.)


StarGeek

As Alan gave you the correct command to shift the time stamps, I'll comment on the other issues.

Quote from: daniello on January 14, 2020, 09:41:02 AM
Only noticeable downside is that rendering takes ages .. seems to rewrite the file .. for 2000 plus image something that should be done overnigt (Intel Core i9)
Quote from: daniello on January 14, 2020, 11:24:43 AM
Speed is much better when running from local SSD - my USB3 USB Stick seemed to be the problem.

Yes, speed is dictated by the source I/O.  Exiftool will run just about as quickly as it would be to copy the image.  If you're using a flash drive or network drive, it will be limited by the speed that the computer can read/write to those drives.  As you were able to see, on an SSD, it will be much quicker.

QuoteFurthermore .. what I don't like about this method is that the filedate is touched. In fact it would be good to have the filedate also changed to the updated information that is written to the exif date tag.

Add the -P (preserve) option to keep the same FileModifyDate.  Take note that it is an upper case P.  The lower case p is a different command.

Once you get all the DateTimeOriginal tags correct, you can run this command to fix the FileModifyDate.
exiftool "-FileModifyDate<DateTimeOriginal" /path/to/dir/
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

daniello

Wow .. thanks guys .. very helpful!

I still have to run three iterations but as expected all can be done by exiftools :-)

BTW: I checked the notify box but I don't get notifications .. off-topic .. but any idea?

StarGeek

Quote from: daniello on January 14, 2020, 12:05:31 PM
I wonder what other dates "alldates" should have changed .. since datetimeoriginal seems to be targeting just "one date".

DateTimeOriginal is the most commonly accessed time stamp for most programs, but you can swap in AllDates instead if you want.  That is a shortcut which will update the three most commonly used time stamps, CreateDate, DateTimeOriginal, and ModifyDate.  Depending upon your files, there may be other time stamps.  You can see them all by using this command
exiftool -time:all -g1 -a -s <FileOrDir>

If there are others you which to modify, you can add them in or you can use Time:all to update all of them.  Personally, I'd suggest a more selective approach as there may be some that you don't actually want to update.

QuoteBTW: I checked the notify box but I don't get notifications .. off-topic .. but any idea?

Check you spam folder.  At least with GMail, all the mail from Exiftool.org is being treated as spam.  I had to set GMail to never send messages from noreply@exiftool.org to spam.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

daniello

Since I used the alldates flag I just checked the modified jpeg files and createdate and modifydate are not the same as DateTimeOriginal. Hmm?!

Will deal with spam filter tomorrow .. but you are perfectly right.

Alan Clifford

Quote from: daniello on January 14, 2020, 12:24:46 PM
Since I used the alldates flag I just checked the modified jpeg files and createdate and modifydate are not the same as DateTimeOriginal. Hmm?!


To comment on that, I think we would need a copy of the photo before, the command line you used and the photo after.

daniello

Thanks Alan .. didn't get notified thus the late reply.

http://ge.tt/1h8P8k03

"pictest.zip" contains 3 files:

1. I took the kamera picture and added two hours to the time stamp.
2. Then I ran: exiftool "-alldates<filename" *.jpg

Of the three possible dates only one has been updated (Outputfile: 2020-01-04 20.04.52.jpg)

StarGeek

It helps to include the -a (duplicates) option when listing data.  The command in FAQ #3 is the best one to make sure you see everything.

Using that command, you will see this output:
======== Y:/!temp/zzzz/2020-01-04 18.04.52_kamera.jpg
[ExifIFD]       DateTimeOriginal                : 2020:01:04 18:04:52
[ExifIFD]       CreateDate                      : 2020:01:04 18:04:52
[IFD0]          ModifyDate                      : 2020:01:04 18:04:52
[IFD1]          ModifyDate                      : 2020:01:04 19:34:52
======== Y:/!temp/zzzz/2020-01-04 20.04.52.jpg
[ExifIFD]       DateTimeOriginal                : 2020:01:04 20:04:52
[ExifIFD]       CreateDate                      : 2020:01:04 20:04:52
[IFD0]          ModifyDate                      : 2020:01:04 20:04:52
[IFD1]          ModifyDate                      : 2020:01:04 19:34:52


As you can see, there are two ModifyDate tags.  The one in IFD1 is non standard and shouldn't be there.  Exiftool will not update that one unless it is explicitly targeted.

The IFD1 subdirectory of the EXIF block is supposed to hold data about the embedded thumbnail.  The one in your image includes a lot of data that isn't supposed to be there, including
Make
Model
ImageDescription
Orientation
XResolution
YResolution
ResolutionUnit
Software

It's not uncommon for some cameras to write weird EXIF data (though it annoys the heck out of me).  It won't harm the rendering of the image and most software will probably ignore it (though YMMV).  It's just something to keep in mind if you want to edit any of these tags.

You can deal with this in two ways.  Either remove the non-spec ModifyDate
exiftool -IFD1:ModifyDate= "j:\foldername\"
Or make sure and include it in your command
exiftool "-alldates<filename" "-IFD1:ModifyDate<filename" "j:\foldername\"

* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

Alan Clifford

Quote from: daniello on January 17, 2020, 04:07:09 AM

Of the three possible dates only one has been updated (Outputfile: 2020-01-04 20.04.52.jpg)

What's wrong with the CreateDate?  Looks as though it has been changed to me.

======== 2020-01-04 20.04.52.jpg
[EXIF:ExifIFD]  CreateDate                      : 2020:01:04 20:04:52
[EXIF:IFD0]     ModifyDate                      : 2020:01:04 20:04:52
[EXIF:IFD1]     ModifyDate                      : 2020:01:04 19:34:52
[EXIF:ExifIFD]  DateTimeOriginal                : 2020:01:04 20:04:52


daniello

If I look at the Windows file properties there is a Createdate and a Modifydate. But these probably have nothing to do with Exif. When I run the alldates command both of these aren't edited.

Modifydate reflects the Datestamp I see in the file browser. It updates when I touch that.
Createdate seems to store when the file physically was written and may or may not be changed when edited (depending on whether the tool touches the Datestamp or not).

When I look at the Exif tags with Irfanview I siee DateTime, DateTimeOriginal, DateTimeDigitized plus a DateTime for the Thumbnail [ifd1] and all are the same except for the latter. So I can follow your explanation.

So ultimately I think I confused file tags with exif tags. Thanks everyone for clarifying.

Additionally I see a GPSTimeStamp which is 7 hours off .. will have to look into the manual for that .. I would have expected this to be a correct time .. but that's a new topic ;-)




StarGeek

The time stamps on the Properties->General tab are the file system times.  The ones on the Details tab can come from multiple places, EXIF, IPTC, and XMP.  See this post for info on what tags Windows reads to fill an entry on the Details tab.

Quote from: daniello on January 18, 2020, 12:55:42 AM
When I look at the Exif tags with Irfanview I siee DateTime, DateTimeOriginal, DateTimeDigitized plus a DateTime for the Thumbnail [ifd1] and all are the same except for the latter. So I can follow your explanation.

Exiftool uses CreateDate in place of DateTimeDigitized and ModifyDate instead of DateTime.  DateTimeDigitized and DateTime are the actual names of those tags according to the specs (see the notes column for each of these on the Exif Tags page).  Exiftool uses different names to make it easier to see the correlation between the various tag groups.

QuoteAdditionally I see a GPSTimeStamp which is 7 hours off .. will have to look into the manual for that .. I would have expected this to be a correct time

The GPS time data is split into two different tags, GPSDateStamp and GPSTimeStamp.  Exiftool also provides a tag which combines them called GPSDateTime.  This is in the Composite group, which is made up of tags that exiftool creates out of other tags for ease of use.

The two GPS date/time tags are supposed to be in UTC, so if the time zone where the image was shot is 7 hours off of UTC, then it is set correctly.  So if your time zone is +07:00, then it's set correctly.

There is one other time stamp in those images and it's up to you if you want to deal with it or not.  It's a Sony specific tag, aka a MakersNote tag, which is Sony:SonyDateTime.  You can deal with it the same way as you did with AllDates or you can use exiftool's time shift like Alan described
exiftool -Sony:SonyDateTime-=1:30 <FileOrDir>
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

daniello

Thanks, very interesting!

My basic intent is to have all pictures sorted in the correct order in my album. Having several devices I name all of them in the same way to have them line up correctly. My personal failure is that I forget to set the time in my camera correctly .. most of the times. So in fact my original problem was already fixed early in this thread .. what followed was interest/curiosity.

I checked the camera settings and I believe the camera should do all the time settings for me via gps. I noticed that the time zone was set completly wrong - no idea why the gps didin't cope with that. Maybe because I didn't realize it should work automatically and changed the date/time by hand .. which potentially messed up a lot. Lot's to learn  ::)