Bug #1341

Date/Time Original not modified for NEFs

Added by Jean-Luc CECCOLI 17 days ago. Updated 16 days ago.

Status:AssignedStart date:07 Apr 2018
Priority:NormalDue date:
Assignee:Robin Mills% Done:

100%

Category:metadataEstimated time:1.00 hour
Target version:0.27

Description

Hello,
Ubuntu 16.04 LTS, exiv2 v2.5.
exiv2 -v ad -a -1:00:00 photo.nef states Date/Time Original is modified, but it actually keeps unmodified.
Is a fix for this planned ?
Rgrds,
J.-Luc

History

#1 Updated by Robin Mills 16 days ago

  • Category set to metadata
  • Status changed from New to Assigned
  • Assignee set to Robin Mills
  • Target version set to 0.27
  • % Done changed from 0 to 10
  • Estimated time set to 2.00

Amazing discovery.

Clearly NEF has a metadatum Exif.Image.DateTimeOriginal which is not being updated.
Both JPEG and NEF have Exif.Photo.DateTimeOriginal which is being correctly updated.

JPEG:

$ curl http://clanmills.com/Stonehenge.jpg > S.jpg
$ exiv2 -pa --grep Date/i S.jpg
Exif.Image.DateTime                          Ascii      20  2015:07:16 20:25:28 <-- Last edit 8:25pm
Exif.Photo.DateTimeOriginal                  Ascii      20  2015:07:16 15:38:54 <-- Taken at 3:38pm
Exif.Photo.DateTimeDigitized                 Ascii      20  2015:07:16 15:38:54
Exif.NikonWt.DateDisplayFormat               Byte        1  Y/M/D
Exif.GPSInfo.GPSDateStamp                    Ascii      11  2015:07:16
Xmp.xmp.ModifyDate                           XmpText    25  2015-07-16T20:25:28+01:00
$ exiv2 --verbose -a -1:00:00 S.jpg
File 1/1: S.jpg
Adjusting `Exif.Image.DateTime' by -3600s to 2015:07:16 19:25:28
Adjusting `Exif.Photo.DateTimeOriginal' by -3600s to 2015:07:16 14:38:54
Adjusting `Exif.Photo.DateTimeDigitized' by -3600s to 2015:07:16 14:38:54
$ exiv2 -pa --grep Date/i S.jpg
Exif.Image.DateTime                          Ascii      20  2015:07:16 19:25:28 <-- Now 7:25pm
Exif.Photo.DateTimeOriginal                  Ascii      20  2015:07:16 14:38:54 <-- Now 2:28pm
Exif.Photo.DateTimeDigitized                 Ascii      20  2015:07:16 14:38:54
Exif.NikonWt.DateDisplayFormat               Byte        1  Y/M/D
Exif.GPSInfo.GPSDateStamp                    Ascii      11  2015:07:16
Xmp.xmp.ModifyDate                           XmpText    25  2015-07-16T20:25:28+01:00
NEF:
$ cp /Volumes/Backup/Photos/2016/Raw/DSC_0001.NEF .
$ exiv2 -pa --grep Date/i DSC_0001.NEF 
Exif.Image.DateTime                          Ascii      20  2016:04:20 08:00:13 <-- Last edit 8am
Exif.Photo.DateTimeOriginal                  Ascii      20  2016:04:20 08:00:13 <-- Taken at 8am
Exif.Photo.DateTimeDigitized                 Ascii      20  2016:04:20 08:00:13
Exif.NikonWt.DateDisplayFormat               Byte        1  Y/M/D
Exif.Image.DateTimeOriginal                  Ascii      20  2016:04:20 08:00:13
$ exiv2 --verbose -a -1:00:00 DSC_0001.NEF 
File 1/1: DSC_0001.NEF
Adjusting `Exif.Image.DateTime' by -3600s to 2016:04:20 07:00:13 
Adjusting `Exif.Photo.DateTimeOriginal' by -3600s to 2016:04:20 07:00:13
Adjusting `Exif.Photo.DateTimeDigitized' by -3600s to 2016:04:20 07:00:13
$ exiv2 -pa --grep Date/i DSC_0001.NEF 
Exif.Image.DateTime                          Ascii      20  2016:04:20 07:00:13 <-- Now 7am
Exif.Photo.DateTimeOriginal                  Ascii      20  2016:04:20 07:00:13 <-- Now 7am
Exif.Photo.DateTimeDigitized                 Ascii      20  2016:04:20 07:00:13
Exif.NikonWt.DateDisplayFormat               Byte        1  Y/M/D
Exif.Image.DateTimeOriginal                  Ascii      20  2016:04:20 08:00:13 <-- Oh! 
$ 
This will be fixed in v0.27 which is expected to be released later this year. We don't have a target date for v0.27 at the moment.

#2 Updated by Robin Mills 16 days ago

  • % Done changed from 10 to 20

Ah! This is intentional behaviour. The code to preform this is in src/actions.cpp:

   861            Exiv2::ExifKey key("Exif.Photo.DateTimeOriginal");
   862            Exiv2::ExifData::iterator md = exifData.findKey(key);
   863            if (md == exifData.end()) {
   864                key = Exiv2::ExifKey("Exif.Image.DateTime");
   865                md = exifData.findKey(key);
   866            }
   867            ...

The code updates Exif.Photo.DateTimeOriginal or Exif.Image.DateTime, but not both! Exif.Photo.DateTimeOriginal has priority. This is exactly the behaviour we have seen in the test above.

I can of course modify the code to update both, however I think this is intended behaviour.

Can you describe your use case and the behaviour you would wish to see?

#3 Updated by Robin Mills 16 days ago

  • % Done changed from 20 to 100
  • Estimated time changed from 2.00 to 1.00

Apologies. I misread the code. The code at 861 is modifying the filesystem timestamp using the metadata. That's correct, it has to choose only only one.

The correct fix is:

705 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ git diff
diff --git a/src/actions.cpp b/src/actions.cpp
index b167d19e..16a49a95 100644
--- a/src/actions.cpp
+++ b/src/actions.cpp
@@ -1701,6 +1701,7 @@ namespace Action {
         }
         int rc = adjustDateTime(exifData, "Exif.Image.DateTime", path);
         rc += adjustDateTime(exifData, "Exif.Photo.DateTimeOriginal", path);
+        rc += adjustDateTime(exifData, "Exif.Image.DateTimeOriginal", path);
         rc += adjustDateTime(exifData, "Exif.Photo.DateTimeDigitized", path);

         if (rc == 0 ) {
706 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ 
Here's the output:
706 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ cp /Volumes/Backup/Photos/2016/Raw/DSC_0001.NEF .
707 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ bin/exiv2 -pa --grep date/i DSC_0001.NEF 
Exif.Image.DateTime                          Ascii      20  2016:04:20 08:00:13
Exif.Photo.DateTimeOriginal                  Ascii      20  2016:04:20 08:00:13
Exif.Photo.DateTimeDigitized                 Ascii      20  2016:04:20 08:00:13
Exif.NikonWt.DateDisplayFormat               Byte        1  Y/M/D
Exif.Image.DateTimeOriginal                  Ascii      20  2016:04:20 08:00:13
708 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ bin/exiv2 --verbose --adjust -1:00:00 DSC_0001.NEF
File 1/1: DSC_0001.NEF
Adjusting `Exif.Image.DateTime' by -3600s to 2016:04:20 07:00:13
Adjusting `Exif.Photo.DateTimeOriginal' by -3600s to 2016:04:20 07:00:13
Adjusting `Exif.Image.DateTimeOriginal' by -3600s to 2016:04:20 07:00:13
Adjusting `Exif.Photo.DateTimeDigitized' by -3600s to 2016:04:20 07:00:13
709 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ bin/exiv2 -pa --grep date/i DSC_0001.NEF 
Exif.Image.DateTime                          Ascii      20  2016:04:20 07:00:13
Exif.Photo.DateTimeOriginal                  Ascii      20  2016:04:20 07:00:13
Exif.Photo.DateTimeDigitized                 Ascii      20  2016:04:20 07:00:13
Exif.NikonWt.DateDisplayFormat               Byte        1  Y/M/D
Exif.Image.DateTimeOriginal                  Ascii      20  2016:04:20 07:00:13
710 rmills@rmillsmbp:~/gnu/github/exiv2/exiv2/build $ 

Also available in: Atom PDF

Redmine Appliance - Powered by TurnKey Linux