Date/Time shift, weird 2 days difference

Started by spockk, April 13, 2017, 06:47:58 AM

Previous topic - Next topic

spockk

Hello,
I'm trying to correct wrong date/time of a bunch of 'Canon DIGITAL IXUS 40' pics, incorrectly set from 2004-04-14 to 2005-12-24

With a help of a "reference" pic, which date of shooting i exactly know:
Date in EXIF: 31 Aug 2005
Real date: 19 May 2012
i found out with the help from an online date/time calculator that i need to apply correction of 6 years, 8 days and 18 hours UPD: Wrong, i've made a typo here - 8 months and 18 days to all photos.
While testing this, i noticed strange exiftool 10.20 behaviour (the following examples with 10.49 - same results) on some files.

Before test:
exiftool.exe -time:all -a -s -G1 IMG_1269.jpg
[System]        FileModifyDate                  : 2011:04:28 23:18:44+03:00
[System]        FileAccessDate                  : 2017:04:12 21:55:18+03:00
[System]        FileCreateDate                  : 2017:04:12 21:55:18+03:00
[IFD0]          ModifyDate                      : 2004:04:14 01:22:08
[ExifIFD]       DateTimeOriginal                : 2004:04:14 01:22:08
[ExifIFD]       CreateDate                      : 2004:04:14 01:22:08


exiftool.exe -time:all -a -s -G1 IMG_1423.jpg
[System]        FileModifyDate                  : 2011:05:26 08:56:08+03:00
[System]        FileAccessDate                  : 2017:04:12 21:43:30+03:00
[System]        FileCreateDate                  : 2017:04:12 21:43:30+03:00
[IFD0]          ModifyDate                      : 2004:09:01 16:46:32
[ExifIFD]       DateTimeOriginal                : 2004:09:01 16:46:32
[ExifIFD]       CreateDate                      : 2004:09:01 16:46:32


Correcting IMG_1269.jpg:
d:\photo-razbor\temp>c:\_scripts\exiftool\exiftool.exe -v2 "-DateTimeOriginal+=6:8:18 0:0:0" -ext jpg IMG_1269.jpg
Shifting MIE-Doc:DateTimeOriginal if tag exists
Shifting CanonRaw:DateTimeOriginal if tag exists
Shifting Reconyx:DateTimeOriginal if tag exists
Shifting Kodak:DateTimeOriginal if tag exists
Shifting XMP-exif:DateTimeOriginal if tag exists
Shifting ExifIFD:DateTimeOriginal if tag exists
======== IMG_1269.jpg
Rewriting IMG_1269.jpg...
  Editing tags in: APP0 APP1 CIFF ExifIFD IFD0 JFIF MIE-Doc MakerNotes XMP
  Creating tags in:
JPEG APP1 (11260 bytes):
  Rewriting IFD0
  Rewriting ExifIFD
    - ExifIFD:DateTimeOriginal = '2004:04:14 01:22:08'
    + ExifIFD:DateTimeOriginal = '2011:01:01 01:22:08'
  Rewriting MakerNoteCanon
  Rewriting CanonCameraSettings
  Rewriting CanonFocalLength
  Rewriting CanonShotInfo
  Rewriting CanonCameraInfoUnknown32
  Rewriting InteropIFD
  Rewriting IFD1
JPEG DHT (416 bytes):
JPEG DQT (130 bytes):
JPEG SOF0:
JPEG SOS
    1 image files updated


Correcting IMG_1423.jpg:
exiftool.exe -v2 "-DateTimeOriginal+=6:8:18 0:0:0" -ext jpg IMG_1423.jpg
Shifting MIE-Doc:DateTimeOriginal if tag exists
Shifting CanonRaw:DateTimeOriginal if tag exists
Shifting Kodak:DateTimeOriginal if tag exists
Shifting Reconyx:DateTimeOriginal if tag exists
Shifting XMP-exif:DateTimeOriginal if tag exists
Shifting ExifIFD:DateTimeOriginal if tag exists
======== IMG_1423.jpg
Rewriting IMG_1423.jpg...
  Editing tags in: APP0 APP1 CIFF ExifIFD IFD0 JFIF MIE-Doc MakerNotes XMP
  Creating tags in:
JPEG APP1 (11260 bytes):
  Rewriting IFD0
  Rewriting ExifIFD
    - ExifIFD:DateTimeOriginal = '2004:09:01 16:46:32'
    + ExifIFD:DateTimeOriginal = '2011:05:19 16:46:32'
  Rewriting MakerNoteCanon
  Rewriting CanonCameraSettings
  Rewriting CanonFocalLength
  Rewriting CanonShotInfo
  Rewriting CanonCameraInfoUnknown32
  Rewriting InteropIFD
  Rewriting IFD1
JPEG DHT (416 bytes):
JPEG DQT (130 bytes):
JPEG SOF0:
JPEG SOS
    1 image files updated


Correcting IMG_1269.jpg + IMG_1423.jpg together:
exiftool.exe -v2 -charset FileName=cp1251 "-DateTimeOriginal+=6:8:18 0:0:0" -ext jpg *
Shifting MIE-Doc:DateTimeOriginal if tag exists
Shifting Kodak:DateTimeOriginal if tag exists
Shifting Reconyx:DateTimeOriginal if tag exists
Shifting CanonRaw:DateTimeOriginal if tag exists
Shifting XMP-exif:DateTimeOriginal if tag exists
Shifting ExifIFD:DateTimeOriginal if tag exists
======== IMG_1269.jpg
Rewriting IMG_1269.jpg...
  Editing tags in: APP0 APP1 CIFF ExifIFD IFD0 JFIF MIE-Doc MakerNotes XMP
  Creating tags in:
JPEG APP1 (11260 bytes):
  Rewriting IFD0
  Rewriting ExifIFD
    - ExifIFD:DateTimeOriginal = '2004:04:14 01:22:08'
    + ExifIFD:DateTimeOriginal = '2011:01:01 01:22:08'
  Rewriting MakerNoteCanon
  Rewriting CanonCameraSettings
  Rewriting CanonFocalLength
  Rewriting CanonShotInfo
  Rewriting CanonCameraInfoUnknown32
  Rewriting InteropIFD
  Rewriting IFD1
JPEG DHT (416 bytes):
JPEG DQT (130 bytes):
JPEG SOF0:
JPEG SOS
======== IMG_1423.jpg
Rewriting IMG_1423.jpg...
  Editing tags in: APP0 APP1 CIFF ExifIFD IFD0 JFIF MIE-Doc MakerNotes XMP
  Creating tags in:
JPEG APP1 (11260 bytes):
  Rewriting IFD0
  Rewriting ExifIFD
    - ExifIFD:DateTimeOriginal = '2004:09:01 16:46:32'
    + ExifIFD:DateTimeOriginal = '2011:05:21 16:46:32'
  Rewriting MakerNoteCanon
  Rewriting CanonCameraSettings
  Rewriting CanonFocalLength
  Rewriting CanonShotInfo
  Rewriting CanonCameraInfoUnknown32
  Rewriting InteropIFD
  Rewriting IFD1
JPEG DHT (416 bytes):
JPEG DQT (130 bytes):
JPEG SOF0:
JPEG SOS
    2 image files updated


1. Could anybody explain such a 2 days difference?
2. what is the simplest and 100% correct way to control (calculate manually) date/time shifting? Online resource or with the help of some software?

Thanks beforehand.

Phil Harvey

You are correcting by 6 years 8 months and 18 days.  Instead, I think you wanted this:

exiftool "-DateTimeOriginal+=6:0:8 18:0:0" ...

The difference you observed is because different months have different numbers of days.  See the TRICKY section here for an explanation.

- 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 ($).

spockk

Quote from: Phil Harvey on April 13, 2017, 07:10:35 AM
You are correcting by 6 years 8 months and 18 days.  Instead, I think you wanted this:

exiftool "-DateTimeOriginal+=6:0:8 18:0:0" ...
Unfortunately, the above command produces absolutely wrong date/time shift, the first picture (IMG_1269.jpg) really was taken on 2011:01:01 (The New Year party) and your example gives 2010:04:22.
And here: http://www.exiftool.org/index.html#shift
QuoteThen all of the pictures you took subsequently have timestamps that are wrong by 5 years, 10 months, 2 days, 10 hours and 48 minutes. To fix this, put all of the images in the same directory ("DIR") and run exiftool:

    exiftool "-DateTimeOriginal+=5:10:2 10:48:0" DIR
you clearly explain that shift format is "-DateTimeOriginal+=Years:Months:Days Hours:Minutes:Seconds"

Phil Harvey

You said this:

Quotei need to apply correction of 6 years, 8 days and 18 hours

which is what I did.

- 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 ($).

spockk

I beg your pardon, i've made a typo in original post. It is corrected now.
Again, my apologies.

And i guess probably, why i get that 2 days wrong shift.
According to your "tricky" link:
Quoteshifting the first tag found with the actual specified shift, then calculating the equivalent time difference in seconds for this shift and applying this difference to subsequent tags in a batch conversion
That way, exiftool calculates date shift for the first file and apply the same value for the second... And for some reason that value doesn't match with value, directly calculated with the seconf file.

Phil Harvey

That is correct.  ExifTool applies a constant time shift (in seconds) for all files in a command, which is usually what you want.  The time shift is calculated from the first processed file, and all subsequent files will have the same time shift.

If you want different shifts for different files, you must run separate commands.

This is all fairly simple to understand once you realize that the number of days in a month (and a year) depends on the starting 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 ($).

spockk

Quote from: Phil Harvey on April 13, 2017, 08:05:58 AM
That is correct.  ExifTool applies a constant time shift (in seconds) for all files in a command, which is usually what you want.  The time shift is calculated from the first processed file, and all subsequent files will have the same time shift.

If you want different shifts for different files, you must run separate commands.

This is all fairly simple to understand once you realize that the number of days in a month (and a year) depends on the starting date.

- Phil
Phil, i have a strong feeling that something left unclear. Or I just don't understand some simple thing.
I read here: http://www.exiftool.org/index.html#shift
QuoteThen all of the pictures you took subsequently have timestamps that are wrong by 5 years, 10 months, 2 days, 10 hours and 48 minutes. To fix this, put all of the images in the same directory ("DIR") and run exiftool:
Is the above actual or obsolete?
All of my pictures have timestamps that are wrong by 6 years 8 months and 18 days. And as described above i put all stuff in one directory then run:
exiftool.exe -v2 "-DateTimeOriginal+=6:8:18 0:0:0" -ext jpg *
Then i get incorrect date shifting starting from the second picture.
So, if documentation from the link above is correct, why i get such results?

Furthermore, i've done some new tests, which confused me much more:
exiftool batch shift of my pics in the following order: 1. IMG_1269.jpg, 2. IMG_1414.jpg 3. IMG_1423.jpg
exiftool.exe -v2 "-DateTimeOriginal+=6:8:18 0:0:0" -ext jpg *
======== 01-IMG_1269.jpg
Rewriting 01-IMG_1269.jpg...
    - ExifIFD:DateTimeOriginal = '2004:04:14 01:22:08'
    + ExifIFD:DateTimeOriginal = '2011:01:01 01:22:08'
======== 02-IMG_1414.jpg
Rewriting 02-IMG_1414.jpg...
    - ExifIFD:DateTimeOriginal = '2004:09:01 14:38:30'
    + ExifIFD:DateTimeOriginal = '2011:05:21 14:38:30'
======== 03-IMG_1423.jpg
Rewriting 03-IMG_1423.jpg...
    - ExifIFD:DateTimeOriginal = '2004:09:01 16:46:32'
    + ExifIFD:DateTimeOriginal = '2011:05:21 16:46:32'
    3 image files updated

exiftool batch shift of my pics in the following order: 1. IMG_1414.jpg, 2. IMG_1423.jpg 3. IMG_1269.jpg
exiftool.exe -v2 "-DateTimeOriginal+=6:8:18 0:0:0" -ext jpg *
======== 01-IMG_1414.jpg
Rewriting 01-IMG_1414.jpg...
    - ExifIFD:DateTimeOriginal = '2004:09:01 14:38:30'
    + ExifIFD:DateTimeOriginal = '2011:05:19 14:38:30'
======== 02-IMG_1423.jpg
Rewriting 02-IMG_1423.jpg...
    - ExifIFD:DateTimeOriginal = '2004:09:01 16:46:32'
    + ExifIFD:DateTimeOriginal = '2011:05:19 16:46:32'
======== 03-IMG_1269.jpg
Rewriting 03-IMG_1269.jpg...
    - ExifIFD:DateTimeOriginal = '2004:04:14 01:22:08'
    + ExifIFD:DateTimeOriginal = '2010:12:30 01:22:08'
    3 image files updated


Could you explain me the math?
What is the correct shift by by 6 years 8 months and 18 days of, say, IMG_1423.jpg: 2011:05:19 or 2011:05:21?
Could you recommend an precise online calculator or tool, that produces correct calculations to manually control results?
If batch shifting produces incorrect results as in my case, probably you would recommend to shift dates file by file, not in a batch?

Phil Harvey

#7
Why are the times wrong in the original pictures?  If it was because the camera clock was set wrong, and the clock wasn't reset between any of the pictures, then you need to apply a constant time difference, which is what ExifTool does.

If the camera clock was reset between pictures, then you need to run different command for each different group of pictures with the same camera clock setting.

I don't know if you understand that a a shift of 8 months is not a constant shift.  If you add exactly 8 months to all pictures then the time shifts will not correspond to a constant error in your camera clock.

For example, if you set your camera clock to June 1 when it was actually March 1 then took two pictures, the first on March 1 and the second on April 1, then do you understand that the timestamps on those pictures will be June 1 and July 2?  (NOT June 1 and July 1)  This is because you took the pictures 31 days apart, but there are only 30 days in June.

- Phil

Edit:  I don't think you need an online calculator tool.  I just think you need to understand what you are trying to do.
...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 ($).

spockk

Phil, thank you for your patience and answers.
Than more i'm trying to understand things behind date shifting, than more i feel confused.
Probably i'm doing something wrong from the start.
So i need your advice.
Quote from: Phil Harvey on April 13, 2017, 09:54:04 AM
Why are the times wrong in the original pictures?  If it was because the camera clock was set wrong, and the clock wasn't reset between any of the pictures, then you need to apply a constant time difference, which is what ExifTool does.
In late 2010 my father's camera came from repair service with wrong date/time. He corrected time only, keeping date and year intact.
Then he started shooting on (approximately) 01-01-2011 with date set as 2004-04-14. The clock in camera was ticking that way until Sep 2012, when his mistake was corrected by me, so he managed to get exactly 921 bad timestamped pictures.
Now i need to fix my father's mistake. Yesterday I have found a few pictures that were taken on 2012-05-19:
QuoteWith a help of a "reference" pic, which date of shooting i exactly know:
Date in EXIF: 31 Aug 2005
Real date: 19 May 2012
i found out with the help from an online date/time calculator that i need to apply correction of 6 years, 8 months and 18 days to all photos.

So i need advice how to correct all those 921 pics, taking into consideration that years 2004, 2008 were leap and all months are not necessary have 30 days.
Thank you very much in advance.

StarGeek

You could use a date calculator  to get the number of days and use that to shift the timestamp.  In this case, using your original dates, April 14, 2004 and January 1, 2011, it came up with 2,453 days.  I set my test file to August 31, 2005, then shifted 2,453 days to get your target of May 19, 2012.

C:\Programs>exiftool -DateTimeOriginal X:\!temp\Test3.jpg
Date/Time Original              : 2005:08:31 01:01:01

C:\Programs>exiftool -overwrite_original -DateTimeOriginal+="2453 0" X:\!temp\Test3.jpg
    1 image files updated

C:\Programs>exiftool -DateTimeOriginal X:\!temp\Test3.jpg
Date/Time Original              : 2012:05:19 01:01:01


* 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).