Bug 139264

Summary: digikam sorts pictures with wrong exif tag
Product: [Applications] digikam Reporter: Yuchen Wang <cosmorning>
Component: Metadata-ExifAssignee: Digikam Developers <digikam-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: bluedrago, frederic.coiffier
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In: 0.9.1
Attachments: screenshot for digikam 0.9.0
digikam-exif-date.patch

Description Yuchen Wang 2006-12-27 04:39:46 UTC
Version:           0.9.0, with kipi library version 0.1.4 (using KDE KDE 3.5.1)
Installed from:    SuSE RPMs
OS:                Linux

I started using digikam to manage my pictures recently. I am using version 0.9.0. However, I found when I switched to calendar view (Dates view), digikam sorts my pictures by an EXIF tag "DateTime", instead of tag "DateTimeOriginal". I have some pictures touched by Adoble Photoshop Album, which changed the tag "DateTime". See my attachment. The picture was taken on 12/21/2005, but processed from raw in 1/1/2006. However, it shows up in my calendar January 2006. I think it is better to sort pictures by tag "DateTimeOriginal" if it is available, since this field holds most trustable information for the picture. Following is the print out of the exiv2 from command line: 

Exif.Image.DateTime                          Ascii      20  2006:01:01 22:36:19
Exif.Image.YCbCrPositioning                  Short       1  Centered
Exif.Image.ReferenceBlackWhite               Rational    6  0/1 255/1 0/1 255/1 0/1 255/1
Exif.Image.ExifTag                           Long        1  284
Exif.Photo.ExposureTime                      Rational    1  1/500 s
Exif.Photo.FNumber                           Rational    1  F11
Exif.Photo.ExposureProgram                   Short       1  Auto
Exif.Photo.ExifVersion                       Undefined   4  48 50 50 48
Exif.Photo.DateTimeOriginal                  Ascii      20  2005:12:21 08:35:23
Exif.Photo.DateTimeDigitized                 Ascii      20  2005:12:21 11:35:23

Please take a look. Thanks.
Comment 1 Yuchen Wang 2006-12-27 04:40:55 UTC
Created attachment 19043 [details]
screenshot for digikam 0.9.0

screenshot for digikam 0.9.0
Comment 2 Yuchen Wang 2006-12-30 09:36:55 UTC
according to exif spec 2.2:

        DateTime
        The date and time of image creation. In this standard it is the
        date and time the file was changed.
       
        DateTimeOriginal
        The date and time when the original image data was generated.
        For a DSC the date and time the picture was taken are recorded. 

Hence I believe when digikam should sort pictures by DateTimeOriginal, NOT DateTime.
Comment 3 Mikolaj Machowski 2006-12-30 20:10:56 UTC
Agree with you. Looks like datetime used for Date view is taken from
database. Wrong data is taken when importing photo into albumdb.
Comment 4 Dennis Gnad 2007-01-24 22:24:01 UTC
Ah... I can confirm it.
It's a duplicate of <i><a href="show_bug.cgi?id=135011" title="UNCONFIRMED - Sort images by EXIF date seems buggy for Nikon (or not just Nikon?)">bug 135011</a></i>
Comment 5 Luka Renko 2007-01-24 22:44:36 UTC
*** Bug 135011 has been marked as a duplicate of this bug. ***
Comment 6 Luka Renko 2007-01-24 23:49:41 UTC
Created attachment 19399 [details]
digikam-exif-date.patch

Proposed patch for DMetadata::getImageDateTime() method to prefer
DateTimeOriginal and DateTimeDigitized before DateTime (which is typically
changed by photo editing   software). 

I think we should get this in 0.9.1 (together with improvements for Exif/ITPC
sync), but would like to get this reviewed by at least one of more experienced
Digikam developer before committing into SVN.
Comment 7 caulier.gilles 2007-01-25 15:44:41 UTC
Luka,

This patch is fine for me. You can apply it to svn.

Also, you need to make a patch into KipiPlugins::Exiv2Iface class witch is a duplicate code for plugins...

Yes, duplicate code is wrong. we need to merge it into a shared libkexiv2 library. Now, like kipi-plugins 0.1.3 is released, i will start this implementation in my computer (:=)))...

Gilles
Comment 8 Luka Renko 2007-01-25 16:14:50 UTC
SVN commit 627043 by lure:

Prefer Exif DateTimeOriginal for sorting images (DateTimeDigitized and DateTime only used as fallback)

BUG: 139264


 M  +2 -1      NEWS  
 M  +18 -17    libs/dmetadata/dmetadata.cpp  


--- trunk/extragear/graphics/digikam/NEWS #627042:627043
@@ -470,6 +470,7 @@
 275 ==> 140320 : View menu should better fit after Edit.
 276 ==> 127617 : "Toggle Fullscreen" should be located in "View" menu instead 
                  of "Settings" menu.
-277 ==> 
+277 ==> 139264 : Prefer Exif DateTimeOriginal for sorting images (DateTimeDigitized and DateTime only used as fallback)
+278 ==>
 
 ---------------------------------------------------------------------------------------------------- 
--- trunk/extragear/graphics/digikam/libs/dmetadata/dmetadata.cpp #627042:627043
@@ -812,25 +812,9 @@
         
         if (!d->exifMetadata.empty())
         {        
-            // Try standard Exif date time entry.
+            // Try Exif date time original.
     
-            Exiv2::ExifKey key("Exif.Image.DateTime");
             Exiv2::ExifData exifData(d->exifMetadata);
-            Exiv2::ExifData::iterator it = exifData.findKey(key);
-            
-            if (it != exifData.end())
-            {
-                QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
-    
-                if (dateTime.isValid())
-                {
-                    // DDebug() << "DateTime (Exif standard): " << dateTime << endl;
-                    return dateTime;
-                }
-            }
-    
-            // Bogus standard Exif date time entry. Try Exif date time original.
-    
             Exiv2::ExifKey key2("Exif.Photo.DateTimeOriginal");
             Exiv2::ExifData::iterator it2 = exifData.findKey(key2);
             
@@ -860,6 +844,23 @@
                     return dateTime;
                 }
             }
+
+            // Bogus Exif date time digitalized entry. Try standard Exif date time entry.
+    
+            Exiv2::ExifKey key("Exif.Image.DateTime");
+            Exiv2::ExifData::iterator it = exifData.findKey(key);
+            
+            if (it != exifData.end())
+            {
+                QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
+    
+                if (dateTime.isValid())
+                {
+                    // DDebug() << "DateTime (Exif standard): " << dateTime << endl;
+                    return dateTime;
+                }
+            }
+    
         }
         
         // In second, trying to get Date & time from Iptc tags.
Comment 9 Luka Renko 2007-01-25 16:56:01 UTC
SVN commit 627061 by lure:

Prefer Exif DateTimeOriginal for image date/time (DateTimeDigitized and DateTime only used as fallback)

CCBUG: 139264



 M  +7 -0      NEWS  
 M  +18 -17    common/exiv2iface/exiv2iface.cpp  


--- trunk/extragear/libs/kipi-plugins/NEWS #627060:627061
@@ -1,6 +1,13 @@
 Note: for details and info about current version, see ChangeLog.
 
+v 0.1.4 beta1 
+----------------------------------------------------------------------------
 
+Kipi-plugins NEW FEATURES
+
+Kipi-plugins BUG FIXING from B.K.O (http://bugs.kde.org):
+001 ==> 139264 : General     : Prefer Exif DateTimeOriginal for image date/time (DateTimeDigitized and DateTime only used as fallback)
+
 v 0.1.3 
 ----------------------------------------------------------------------------
 
--- trunk/extragear/libs/kipi-plugins/common/exiv2iface/exiv2iface.cpp #627060:627061
@@ -732,25 +732,9 @@
         
         if (!d->exifMetadata.empty())
         {        
-            // Try standard Exif date time entry.
+            // Try Exif date time original.
     
-            Exiv2::ExifKey key("Exif.Image.DateTime");
             Exiv2::ExifData exifData(d->exifMetadata);
-            Exiv2::ExifData::iterator it = exifData.findKey(key);
-            
-            if (it != exifData.end())
-            {
-                QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
-    
-                if (dateTime.isValid())
-                {
-                    // kdDebug() << "DateTime (Exif standard): " << dateTime << endl;
-                    return dateTime;
-                }
-            }
-    
-            // Bogus standard Exif date time entry. Try Exif date time original.
-    
             Exiv2::ExifKey key2("Exif.Photo.DateTimeOriginal");
             Exiv2::ExifData::iterator it2 = exifData.findKey(key2);
             
@@ -780,6 +764,23 @@
                     return dateTime;
                 }
             }
+
+            // Bogus Exif date time digitized. Try standard Exif date time entry.
+    
+            Exiv2::ExifKey key("Exif.Image.DateTime");
+            Exiv2::ExifData::iterator it = exifData.findKey(key);
+            
+            if (it != exifData.end())
+            {
+                QDateTime dateTime = QDateTime::fromString(it->toString().c_str(), Qt::ISODate);
+    
+                if (dateTime.isValid())
+                {
+                    // kdDebug() << "DateTime (Exif standard): " << dateTime << endl;
+                    return dateTime;
+                }
+            }
+    
         }
         
         // In second, trying to get Date & time from Iptc tags.
Comment 10 Luka Renko 2007-02-05 23:43:46 UTC
*** Bug 137383 has been marked as a duplicate of this bug. ***
Comment 11 Paweł Marciniak 2007-06-06 14:29:53 UTC
Actually, I don't agree with the preference of DateTimeOriginal to DateTimeDigitized, at least as long as digiKam "Adjust Time & Date" feature changes only the latter.

It often happens that I collect pictures from my friends' cameras that don't have their clocks fully synchronized. Then I would like to adjust (in batches) the dates to that all pictures "fit" together. Currently this is impossible, because digiKam would still sort images using the original date that remains unchanged.

Has really nobody encountered this restriction so far?